@synnaxlabs/client 0.2.1 → 0.13.6

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 (299) hide show
  1. package/.eslintrc.cjs +18 -0
  2. package/.pytest_cache/README.md +8 -0
  3. package/.turbo/turbo-build.log +16 -0
  4. package/LICENSE +4 -21
  5. package/{build/module/lib → dist/auth}/auth.d.ts +16 -19
  6. package/dist/auth/index.d.ts +1 -0
  7. package/dist/cdc/external.d.ts +1 -0
  8. package/dist/cdc/index.d.ts +1 -0
  9. package/dist/cdc/observable.d.ts +17 -0
  10. package/dist/channel/client.d.ts +58 -0
  11. package/dist/channel/creator.d.ts +8 -0
  12. package/dist/channel/external.d.ts +4 -0
  13. package/dist/channel/index.d.ts +1 -0
  14. package/dist/channel/payload.d.ts +63 -0
  15. package/dist/channel/retriever.d.ts +49 -0
  16. package/dist/client.cjs.js +23050 -0
  17. package/dist/client.cjs.js.map +1 -0
  18. package/dist/client.d.ts +73 -0
  19. package/dist/client.es.js +23050 -0
  20. package/dist/client.es.js.map +1 -0
  21. package/dist/connection/checker.d.ts +66 -0
  22. package/dist/connection/index.d.ts +1 -0
  23. package/dist/control/authority.d.ts +6 -0
  24. package/dist/control/external.d.ts +2 -0
  25. package/dist/control/index.d.ts +1 -0
  26. package/dist/control/state.d.ts +81 -0
  27. package/{build/main/lib → dist}/errors.d.ts +6 -3
  28. package/dist/framer/adapter.d.ts +21 -0
  29. package/dist/framer/client.d.ts +44 -0
  30. package/dist/framer/external.d.ts +5 -0
  31. package/dist/framer/frame.d.ts +251 -0
  32. package/dist/framer/index.d.ts +1 -0
  33. package/{build/module/lib/segment → dist/framer}/iterator.d.ts +32 -64
  34. package/dist/framer/streamProxy.d.ts +12 -0
  35. package/dist/framer/streamer.d.ts +17 -0
  36. package/dist/framer/writer.d.ts +257 -0
  37. package/dist/index.d.ts +16 -0
  38. package/dist/label/client.d.ts +25 -0
  39. package/dist/label/external.d.ts +4 -0
  40. package/dist/label/index.d.ts +1 -0
  41. package/dist/label/payload.d.ts +20 -0
  42. package/dist/label/retriever.d.ts +13 -0
  43. package/dist/label/writer.d.ts +26 -0
  44. package/dist/ontology/cdc.d.ts +25 -0
  45. package/dist/ontology/client.d.ts +25 -0
  46. package/dist/ontology/external.d.ts +3 -0
  47. package/dist/ontology/group/client.d.ts +11 -0
  48. package/dist/ontology/group/external.d.ts +2 -0
  49. package/dist/ontology/group/group.d.ts +7 -0
  50. package/dist/ontology/group/index.d.ts +1 -0
  51. package/dist/ontology/group/payload.d.ts +40 -0
  52. package/dist/ontology/group/writer.d.ts +13 -0
  53. package/dist/ontology/index.d.ts +1 -0
  54. package/dist/ontology/ontology.spec.d.ts +1 -0
  55. package/dist/ontology/payload.d.ts +235 -0
  56. package/dist/ontology/retriever.d.ts +12 -0
  57. package/dist/ontology/signals.d.ts +25 -0
  58. package/dist/ontology/writer.d.ts +9 -0
  59. package/dist/ranger/active.d.ts +9 -0
  60. package/dist/ranger/alias.d.ts +32 -0
  61. package/dist/ranger/client.d.ts +31 -0
  62. package/dist/ranger/external.d.ts +6 -0
  63. package/dist/ranger/index.d.ts +1 -0
  64. package/dist/ranger/kv.d.ts +50 -0
  65. package/dist/ranger/payload.d.ts +94 -0
  66. package/dist/ranger/range.d.ts +29 -0
  67. package/dist/ranger/ranger.spec.d.ts +1 -0
  68. package/dist/ranger/retriever.d.ts +10 -0
  69. package/dist/ranger/writer.d.ts +9 -0
  70. package/{build/main → dist}/setupspecs.d.ts +2 -2
  71. package/dist/signals/external.d.ts +1 -0
  72. package/dist/signals/index.d.ts +1 -0
  73. package/dist/signals/observable.d.ts +17 -0
  74. package/dist/transport.d.ts +10 -0
  75. package/dist/user/index.d.ts +1 -0
  76. package/{build/main/lib → dist}/user/payload.d.ts +3 -3
  77. package/dist/util/telem.d.ts +2 -0
  78. package/dist/workspace/client.d.ts +22 -0
  79. package/dist/workspace/external.d.ts +2 -0
  80. package/dist/workspace/index.d.ts +1 -0
  81. package/dist/workspace/lineplot/client.d.ts +15 -0
  82. package/dist/workspace/lineplot/external.d.ts +2 -0
  83. package/dist/workspace/lineplot/index.d.ts +1 -0
  84. package/dist/workspace/lineplot/linePlot.spec.d.ts +1 -0
  85. package/dist/workspace/lineplot/payload.d.ts +31 -0
  86. package/dist/workspace/lineplot/retriever.d.ts +9 -0
  87. package/dist/workspace/lineplot/writer.d.ts +39 -0
  88. package/dist/workspace/payload.d.ts +31 -0
  89. package/dist/workspace/pid/client.d.ts +16 -0
  90. package/dist/workspace/pid/external.d.ts +2 -0
  91. package/dist/workspace/pid/index.d.ts +1 -0
  92. package/dist/workspace/pid/payload.d.ts +37 -0
  93. package/dist/workspace/pid/pid.spec.d.ts +1 -0
  94. package/dist/workspace/pid/retriever.d.ts +9 -0
  95. package/dist/workspace/pid/writer.d.ts +46 -0
  96. package/dist/workspace/retriever.d.ts +12 -0
  97. package/dist/workspace/workspace.spec.d.ts +1 -0
  98. package/dist/workspace/writer.d.ts +55 -0
  99. package/package.json +27 -98
  100. package/src/auth/auth.spec.ts +46 -0
  101. package/src/auth/auth.ts +83 -0
  102. package/src/auth/index.ts +10 -0
  103. package/src/channel/channel.spec.ts +82 -0
  104. package/src/channel/client.ts +209 -0
  105. package/src/channel/creator.ts +43 -0
  106. package/src/channel/external.ts +13 -0
  107. package/src/channel/index.ts +10 -0
  108. package/src/channel/payload.ts +52 -0
  109. package/src/channel/retriever.ts +160 -0
  110. package/src/client.ts +116 -0
  111. package/src/connection/checker.ts +104 -0
  112. package/src/connection/connection.spec.ts +35 -0
  113. package/src/connection/index.ts +10 -0
  114. package/src/control/authority.ts +26 -0
  115. package/src/control/external.ts +11 -0
  116. package/src/control/index.ts +10 -0
  117. package/src/control/state.spec.ts +24 -0
  118. package/src/control/state.ts +133 -0
  119. package/src/errors.ts +163 -0
  120. package/src/framer/adapter.ts +116 -0
  121. package/src/framer/client.ts +116 -0
  122. package/src/framer/external.ts +14 -0
  123. package/src/framer/frame.spec.ts +317 -0
  124. package/src/framer/frame.ts +412 -0
  125. package/src/framer/index.ts +10 -0
  126. package/src/framer/iterator.spec.ts +62 -0
  127. package/src/framer/iterator.ts +240 -0
  128. package/src/framer/streamProxy.ts +59 -0
  129. package/src/framer/streamer.spec.ts +42 -0
  130. package/src/framer/streamer.ts +86 -0
  131. package/src/framer/writer.spec.ts +52 -0
  132. package/src/framer/writer.ts +236 -0
  133. package/src/index.ts +53 -0
  134. package/src/label/client.ts +103 -0
  135. package/src/label/external.ts +13 -0
  136. package/src/label/index.ts +10 -0
  137. package/src/label/label.spec.ts +51 -0
  138. package/src/label/payload.ts +29 -0
  139. package/src/label/retriever.ts +65 -0
  140. package/src/label/writer.ts +90 -0
  141. package/src/ontology/client.ts +104 -0
  142. package/src/ontology/external.ts +12 -0
  143. package/src/ontology/group/client.ts +40 -0
  144. package/src/ontology/group/external.ts +11 -0
  145. package/src/ontology/group/group.spec.ts +46 -0
  146. package/src/ontology/group/group.ts +27 -0
  147. package/src/ontology/group/index.ts +10 -0
  148. package/src/ontology/group/payload.ts +65 -0
  149. package/src/ontology/group/writer.ts +48 -0
  150. package/src/ontology/index.ts +10 -0
  151. package/src/ontology/ontology.spec.ts +114 -0
  152. package/src/ontology/payload.ts +118 -0
  153. package/src/ontology/retriever.ts +91 -0
  154. package/src/ontology/signals.ts +135 -0
  155. package/src/ontology/writer.ts +49 -0
  156. package/src/ranger/active.ts +56 -0
  157. package/src/ranger/alias.ts +183 -0
  158. package/src/ranger/client.ts +129 -0
  159. package/src/ranger/external.ts +15 -0
  160. package/src/ranger/index.ts +10 -0
  161. package/src/ranger/kv.ts +91 -0
  162. package/src/ranger/payload.ts +70 -0
  163. package/src/ranger/range.ts +95 -0
  164. package/src/ranger/ranger.spec.ts +201 -0
  165. package/src/ranger/retriever.ts +50 -0
  166. package/src/ranger/writer.ts +80 -0
  167. package/src/setupspecs.ts +25 -0
  168. package/src/signals/external.ts +10 -0
  169. package/src/signals/index.ts +10 -0
  170. package/src/signals/observable.ts +80 -0
  171. package/src/transport.ts +39 -0
  172. package/src/user/index.ts +10 -0
  173. package/src/user/payload.ts +17 -0
  174. package/src/util/telem.ts +19 -0
  175. package/src/vite-env.d.ts +11 -0
  176. package/src/workspace/client.ts +75 -0
  177. package/src/workspace/external.ts +11 -0
  178. package/src/workspace/index.ts +10 -0
  179. package/src/workspace/lineplot/client.ts +51 -0
  180. package/src/workspace/lineplot/external.ts +11 -0
  181. package/src/workspace/lineplot/index.ts +10 -0
  182. package/src/workspace/lineplot/linePlot.spec.ts +78 -0
  183. package/src/workspace/lineplot/payload.ts +29 -0
  184. package/src/workspace/lineplot/retriever.ts +49 -0
  185. package/src/workspace/lineplot/writer.ts +109 -0
  186. package/src/workspace/payload.ts +29 -0
  187. package/src/workspace/pid/client.ts +55 -0
  188. package/src/workspace/pid/external.ts +11 -0
  189. package/src/workspace/pid/index.ts +10 -0
  190. package/src/workspace/pid/payload.ts +31 -0
  191. package/src/workspace/pid/pid.spec.ts +111 -0
  192. package/src/workspace/pid/retriever.ts +45 -0
  193. package/src/workspace/pid/writer.ts +130 -0
  194. package/src/workspace/retriever.ts +66 -0
  195. package/src/workspace/workspace.spec.ts +62 -0
  196. package/src/workspace/writer.ts +103 -0
  197. package/tsconfig.json +7 -0
  198. package/tsconfig.vite.json +4 -0
  199. package/vite.config.ts +25 -0
  200. package/CHANGELOG.md +0 -5
  201. package/build/main/index.d.ts +0 -4
  202. package/build/main/index.js +0 -35
  203. package/build/main/lib/auth.d.ts +0 -54
  204. package/build/main/lib/auth.js +0 -62
  205. package/build/main/lib/auth.spec.js +0 -39
  206. package/build/main/lib/channel/channel.spec.js +0 -49
  207. package/build/main/lib/channel/client.d.ts +0 -94
  208. package/build/main/lib/channel/client.js +0 -134
  209. package/build/main/lib/channel/creator.d.ts +0 -19
  210. package/build/main/lib/channel/creator.js +0 -44
  211. package/build/main/lib/channel/payload.d.ts +0 -25
  212. package/build/main/lib/channel/payload.js +0 -18
  213. package/build/main/lib/channel/registry.d.ts +0 -9
  214. package/build/main/lib/channel/registry.js +0 -37
  215. package/build/main/lib/channel/retriever.d.ts +0 -11
  216. package/build/main/lib/channel/retriever.js +0 -39
  217. package/build/main/lib/client.d.ts +0 -30
  218. package/build/main/lib/client.js +0 -46
  219. package/build/main/lib/errors.js +0 -122
  220. package/build/main/lib/segment/client.d.ts +0 -62
  221. package/build/main/lib/segment/client.js +0 -95
  222. package/build/main/lib/segment/iterator.d.ts +0 -134
  223. package/build/main/lib/segment/iterator.js +0 -253
  224. package/build/main/lib/segment/iterator.spec.js +0 -73
  225. package/build/main/lib/segment/payload.d.ts +0 -16
  226. package/build/main/lib/segment/payload.js +0 -13
  227. package/build/main/lib/segment/splitter.d.ts +0 -7
  228. package/build/main/lib/segment/splitter.js +0 -25
  229. package/build/main/lib/segment/typed.d.ts +0 -15
  230. package/build/main/lib/segment/typed.js +0 -49
  231. package/build/main/lib/segment/validator.d.ts +0 -22
  232. package/build/main/lib/segment/validator.js +0 -64
  233. package/build/main/lib/segment/writer.d.ts +0 -98
  234. package/build/main/lib/segment/writer.js +0 -183
  235. package/build/main/lib/segment/writer.spec.js +0 -90
  236. package/build/main/lib/telem.d.ts +0 -395
  237. package/build/main/lib/telem.js +0 -553
  238. package/build/main/lib/telem.spec.js +0 -152
  239. package/build/main/lib/transport.d.ts +0 -10
  240. package/build/main/lib/transport.js +0 -22
  241. package/build/main/lib/user/payload.js +0 -9
  242. package/build/main/lib/util/telem.d.ts +0 -2
  243. package/build/main/lib/util/telem.js +0 -13
  244. package/build/main/setupspecs.js +0 -17
  245. package/build/module/index.d.ts +0 -4
  246. package/build/module/index.js +0 -5
  247. package/build/module/lib/auth.js +0 -63
  248. package/build/module/lib/auth.spec.js +0 -34
  249. package/build/module/lib/channel/channel.spec.js +0 -44
  250. package/build/module/lib/channel/client.d.ts +0 -94
  251. package/build/module/lib/channel/client.js +0 -134
  252. package/build/module/lib/channel/creator.d.ts +0 -19
  253. package/build/module/lib/channel/creator.js +0 -42
  254. package/build/module/lib/channel/payload.d.ts +0 -25
  255. package/build/module/lib/channel/payload.js +0 -15
  256. package/build/module/lib/channel/registry.d.ts +0 -9
  257. package/build/module/lib/channel/registry.js +0 -36
  258. package/build/module/lib/channel/retriever.d.ts +0 -11
  259. package/build/module/lib/channel/retriever.js +0 -37
  260. package/build/module/lib/client.d.ts +0 -30
  261. package/build/module/lib/client.js +0 -44
  262. package/build/module/lib/errors.d.ts +0 -53
  263. package/build/module/lib/errors.js +0 -113
  264. package/build/module/lib/segment/client.d.ts +0 -62
  265. package/build/module/lib/segment/client.js +0 -94
  266. package/build/module/lib/segment/iterator.js +0 -248
  267. package/build/module/lib/segment/iterator.spec.js +0 -68
  268. package/build/module/lib/segment/payload.d.ts +0 -16
  269. package/build/module/lib/segment/payload.js +0 -10
  270. package/build/module/lib/segment/splitter.d.ts +0 -7
  271. package/build/module/lib/segment/splitter.js +0 -26
  272. package/build/module/lib/segment/typed.d.ts +0 -15
  273. package/build/module/lib/segment/typed.js +0 -49
  274. package/build/module/lib/segment/validator.d.ts +0 -22
  275. package/build/module/lib/segment/validator.js +0 -60
  276. package/build/module/lib/segment/writer.d.ts +0 -98
  277. package/build/module/lib/segment/writer.js +0 -183
  278. package/build/module/lib/segment/writer.spec.js +0 -85
  279. package/build/module/lib/telem.d.ts +0 -395
  280. package/build/module/lib/telem.js +0 -545
  281. package/build/module/lib/telem.spec.js +0 -147
  282. package/build/module/lib/transport.d.ts +0 -10
  283. package/build/module/lib/transport.js +0 -22
  284. package/build/module/lib/user/payload.d.ts +0 -12
  285. package/build/module/lib/user/payload.js +0 -6
  286. package/build/module/lib/util/telem.d.ts +0 -2
  287. package/build/module/lib/util/telem.js +0 -9
  288. package/build/module/setupspecs.d.ts +0 -4
  289. package/build/module/setupspecs.js +0 -16
  290. /package/{build/main/lib → dist/auth}/auth.spec.d.ts +0 -0
  291. /package/{build/main/lib → dist}/channel/channel.spec.d.ts +0 -0
  292. /package/{build/main/lib/segment/iterator.spec.d.ts → dist/connection/connection.spec.d.ts} +0 -0
  293. /package/{build/main/lib/segment/writer.spec.d.ts → dist/control/state.spec.d.ts} +0 -0
  294. /package/{build/main/lib/telem.spec.d.ts → dist/framer/frame.spec.d.ts} +0 -0
  295. /package/{build/module/lib/segment → dist/framer}/iterator.spec.d.ts +0 -0
  296. /package/{build/module/lib/auth.spec.d.ts → dist/framer/streamer.spec.d.ts} +0 -0
  297. /package/{build/module/lib/segment → dist/framer}/writer.spec.d.ts +0 -0
  298. /package/{build/module/lib/channel/channel.spec.d.ts → dist/label/label.spec.d.ts} +0 -0
  299. /package/{build/module/lib/telem.spec.d.ts → dist/ontology/group/group.spec.d.ts} +0 -0
@@ -0,0 +1,66 @@
1
+ import type { UnaryClient } from "@synnaxlabs/freighter";
2
+ import { TimeSpan } from "@synnaxlabs/x";
3
+ import { z } from "zod";
4
+ export declare const status: z.ZodEnum<["disconnected", "connecting", "connected", "failed"]>;
5
+ export type Status = z.infer<typeof status>;
6
+ export declare const state: z.ZodObject<{
7
+ status: z.ZodEnum<["disconnected", "connecting", "connected", "failed"]>;
8
+ error: z.ZodOptional<z.ZodType<Error, z.ZodTypeDef, Error>>;
9
+ message: z.ZodOptional<z.ZodString>;
10
+ clusterKey: z.ZodString;
11
+ }, "strip", z.ZodTypeAny, {
12
+ status: "disconnected" | "connecting" | "connected" | "failed";
13
+ clusterKey: string;
14
+ error?: Error | undefined;
15
+ message?: string | undefined;
16
+ }, {
17
+ status: "disconnected" | "connecting" | "connected" | "failed";
18
+ clusterKey: string;
19
+ error?: Error | undefined;
20
+ message?: string | undefined;
21
+ }>;
22
+ export type State = z.infer<typeof state>;
23
+ /** Polls a synnax cluster for connectivity information. */
24
+ export declare class Checker {
25
+ private static readonly ENDPOINT;
26
+ static readonly DEFAULT: State;
27
+ private readonly _state;
28
+ private readonly pollFrequency;
29
+ private readonly client;
30
+ private interval?;
31
+ private readonly onChangeHandlers;
32
+ static readonly connectionStateZ: z.ZodObject<{
33
+ status: z.ZodEnum<["disconnected", "connecting", "connected", "failed"]>;
34
+ error: z.ZodOptional<z.ZodType<Error, z.ZodTypeDef, Error>>;
35
+ message: z.ZodOptional<z.ZodString>;
36
+ clusterKey: z.ZodString;
37
+ }, "strip", z.ZodTypeAny, {
38
+ status: "disconnected" | "connecting" | "connected" | "failed";
39
+ clusterKey: string;
40
+ error?: Error | undefined;
41
+ message?: string | undefined;
42
+ }, {
43
+ status: "disconnected" | "connecting" | "connected" | "failed";
44
+ clusterKey: string;
45
+ error?: Error | undefined;
46
+ message?: string | undefined;
47
+ }>;
48
+ /**
49
+ * @param client - The transport client to use for connectivity checks.
50
+ * @param pollFreq - The frequency at which to poll the cluster for
51
+ * connectivity information.
52
+ */
53
+ constructor(client: UnaryClient, pollFreq?: TimeSpan);
54
+ /** Stops the connectivity client from polling the cluster for connectivity */
55
+ stopChecking(): void;
56
+ /**
57
+ * Executes a connectivity check and updates the client status and error, as
58
+ * well as calling any registered change handlers.
59
+ */
60
+ check(): Promise<State>;
61
+ /** @returns a copy of the current client state. */
62
+ get state(): State;
63
+ /** @param callback - The function to call when the client status changes. */
64
+ onChange(callback: (state: State) => void): void;
65
+ private startChecking;
66
+ }
@@ -0,0 +1 @@
1
+ export * as connection from '../connection/checker';
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+ export declare class Authority extends Number {
3
+ static readonly ABSOLUTE = 255;
4
+ static readonly DEFAULT = 1;
5
+ static readonly z: z.ZodUnion<[z.ZodType<Authority, z.ZodTypeDef, Authority>, z.ZodEffects<z.ZodNumber, Authority, number>, z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, Authority, Number>]>;
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from '../control/authority';
2
+ export * from '../control/state';
@@ -0,0 +1 @@
1
+ export * as control from '../control/external';
@@ -0,0 +1,81 @@
1
+ import { type Destructor, observe } from "@synnaxlabs/x";
2
+ import { z } from "zod";
3
+ import { type Key as ChannelKey } from '../channel/payload';
4
+ import { Authority } from '../control/authority';
5
+ import { type Client as FrameClient } from '../framer/client';
6
+ export declare const subjectZ: z.ZodObject<{
7
+ name: z.ZodString;
8
+ key: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ name: string;
11
+ key: string;
12
+ }, {
13
+ name: string;
14
+ key: string;
15
+ }>;
16
+ export interface Subject {
17
+ name: string;
18
+ key: string;
19
+ }
20
+ export declare const stateZ: z.ZodObject<{
21
+ subject: z.ZodObject<{
22
+ name: z.ZodString;
23
+ key: z.ZodString;
24
+ }, "strip", z.ZodTypeAny, {
25
+ name: string;
26
+ key: string;
27
+ }, {
28
+ name: string;
29
+ key: string;
30
+ }>;
31
+ resource: z.ZodNumber;
32
+ authority: z.ZodUnion<[z.ZodType<Authority, z.ZodTypeDef, Authority>, z.ZodEffects<z.ZodNumber, Authority, number>, z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, Authority, Number>]>;
33
+ }, "strip", z.ZodTypeAny, {
34
+ subject: {
35
+ name: string;
36
+ key: string;
37
+ };
38
+ resource: number;
39
+ authority: Authority;
40
+ }, {
41
+ subject: {
42
+ name: string;
43
+ key: string;
44
+ };
45
+ resource: number;
46
+ authority: (number | Number | Authority) & (number | Number | Authority | undefined);
47
+ }>;
48
+ export interface State {
49
+ subject: Subject;
50
+ resource: ChannelKey;
51
+ authority: Authority;
52
+ }
53
+ export declare const filterTransfersByChannelKey: (...resources: ChannelKey[]) => (transfers: Transfer[]) => Transfer[];
54
+ interface Release {
55
+ from: State;
56
+ to?: null;
57
+ }
58
+ interface Acquire {
59
+ from?: null;
60
+ to: State;
61
+ }
62
+ export type Transfer = {
63
+ from: State;
64
+ to: State;
65
+ } | Release | Acquire;
66
+ export declare const transferString: (t: Transfer) => string;
67
+ export declare class StateTracker implements observe.Observable<Transfer[]> {
68
+ readonly states: Map<ChannelKey, State>;
69
+ private readonly streamer;
70
+ private readonly ecd;
71
+ private readonly observer;
72
+ private readonly closePromise;
73
+ private constructor();
74
+ subjects(): Subject[];
75
+ onChange(handler: observe.Handler<Transfer[]>): Destructor;
76
+ close(): Promise<void>;
77
+ static open(client: FrameClient): Promise<StateTracker>;
78
+ private stream;
79
+ private merge;
80
+ }
81
+ export {};
@@ -1,8 +1,8 @@
1
- import { BaseTypedError } from '@synnaxlabs/freighter';
2
- export declare type Field = {
1
+ import { BaseTypedError, type Middleware } from "@synnaxlabs/freighter";
2
+ export interface Field {
3
3
  field: string;
4
4
  message: string;
5
- };
5
+ }
6
6
  declare class BaseError extends BaseTypedError {
7
7
  constructor(message: string);
8
8
  }
@@ -32,6 +32,7 @@ export declare class AuthError extends BaseError {
32
32
  * UnexpectedError is raised when an unexpected error occurs.
33
33
  */
34
34
  export declare class UnexpectedError extends BaseError {
35
+ constructor(message: string);
35
36
  }
36
37
  /**
37
38
  * QueryError is raised when a query error occurs.
@@ -50,4 +51,6 @@ export declare class RouteError extends BaseError {
50
51
  */
51
52
  export declare class ContiguityError extends BaseError {
52
53
  }
54
+ export declare const validateFieldNotNull: (key: string, value: unknown, message?: string) => void;
55
+ export declare const errorsMiddleware: Middleware;
53
56
  export {};
@@ -0,0 +1,21 @@
1
+ import { type Key, type Params } from '../channel/payload';
2
+ import { type Retriever } from '../channel/retriever';
3
+ import { type Frame } from '../framer/frame';
4
+ export declare class BackwardFrameAdapter {
5
+ private adapter;
6
+ retriever: Retriever;
7
+ keys: Key[];
8
+ private constructor();
9
+ static open(retriever: Retriever, channels: Params): Promise<BackwardFrameAdapter>;
10
+ update(channels: Params): Promise<void>;
11
+ adapt(fr: Frame): Frame;
12
+ }
13
+ export declare class ForwardFrameAdapter {
14
+ private adapter;
15
+ retriever: Retriever;
16
+ keys: Key[];
17
+ private constructor();
18
+ static open(retriever: Retriever, channels: Params): Promise<ForwardFrameAdapter>;
19
+ update(channels: Params): Promise<void>;
20
+ adapt(fr: Frame): Frame;
21
+ }
@@ -0,0 +1,44 @@
1
+ import { type StreamClient } from "@synnaxlabs/freighter";
2
+ import { type NativeTypedArray, type Series, type TimeRange, type CrudeTimeStamp, TimeStamp } from "@synnaxlabs/x";
3
+ import { type KeyOrName, type Params } from '../channel/payload';
4
+ import { type Retriever } from '../channel/retriever';
5
+ import { Frame } from '../framer/frame';
6
+ import { Iterator } from '../framer/iterator';
7
+ import { Streamer } from '../framer/streamer';
8
+ import { Writer, type WriterConfig } from '../framer/writer';
9
+ export declare class Client {
10
+ private readonly stream;
11
+ private readonly retriever;
12
+ constructor(stream: StreamClient, retriever: Retriever);
13
+ /**
14
+ * Opens a new iterator over the given channels within the provided time range.
15
+ *
16
+ * @param tr - A time range to iterate over.
17
+ * @param keys - A list of channel keys to iterate over.
18
+ * @returns a new {@link TypedIterator}.
19
+ */
20
+ newIterator(tr: TimeRange, channels: Params): Promise<Iterator>;
21
+ /**
22
+ * Opens a new writer on the given channels.
23
+ *
24
+ * @param keys - The keys of the channels to write to. A writer cannot write to
25
+ * a channel that is not in this list. See the {@link RecordWriter} documentation
26
+ * for more information.
27
+ * @returns a new {@link RecordWriter}.
28
+ */
29
+ newWriter({ start, channels, controlSubject, authorities, }: WriterConfig): Promise<Writer>;
30
+ newStreamer(params: Params, from?: TimeStamp): Promise<Streamer>;
31
+ /**
32
+ * Writes telemetry to the given channel starting at the given timestamp.
33
+ *
34
+ * @param to - The key of the channel to write to.
35
+ * @param start - The starting timestamp of the first sample in data.
36
+ * @param data - The telemetry to write. This telemetry must have the same
37
+ * data type as the channel.
38
+ * @throws if the channel does not exist.
39
+ */
40
+ write(to: KeyOrName, start: CrudeTimeStamp, data: NativeTypedArray): Promise<void>;
41
+ read(tr: TimeRange, channel: KeyOrName): Promise<Series>;
42
+ read(tr: TimeRange, channels: Params): Promise<Frame>;
43
+ private readFrame;
44
+ }
@@ -0,0 +1,5 @@
1
+ export * from '../framer/client';
2
+ export * from '../framer/frame';
3
+ export * from '../framer/iterator';
4
+ export * from '../framer/streamer';
5
+ export * from '../framer/writer';
@@ -0,0 +1,251 @@
1
+ import { Size, Series, TimeRange, DataType } from "@synnaxlabs/x";
2
+ import { z } from "zod";
3
+ import { type KeyOrName, type Keys, type Names, type Params } from '../channel/payload';
4
+ type ColumnType = "key" | "name" | null;
5
+ export type CrudeFrame = Frame | FramePayload | Map<KeyOrName, Series[] | Series> | Record<KeyOrName, Series[] | Series>;
6
+ /**
7
+ * A frame is a collection of related typed arrays keyed to a particular channel. Frames
8
+ * can be keyed by channel name or channel key, but not both.
9
+ *
10
+ * Frames have two important characteristics: alignment and orientation.
11
+ *
12
+ * A frame's alignment defines how correlated the arrays for different channels in the
13
+ * frame are:
14
+ *
15
+ * - A frame is weakly aligned if it meets the time range occupied by all arrays of a
16
+ * particular channel is the same for all channels in the frame. This means that the
17
+ * arrays for a particular channel can have gaps betwen them.
18
+ *
19
+ * - A strongly aligned frame means that all channels share the same rate/index and
20
+ * there are no gaps in time between arrays. Strongly aligned frames are natural
21
+ * to interpret, as the values in a particular 'row' of the frame share the same
22
+ * timestamp. All frames written to Synnax must be strongly aligned.
23
+ *
24
+ * - Unaligned frames don't meet the requirements for weakly or strongly aligned frames.
25
+ * Unaligned frames are common when reading from channels that don't have the same
26
+ * index/rate and are continuous in different periods of time.
27
+ *
28
+ * Frames also have an orientation: horizontal, vertical, or square.
29
+ *
30
+ * - Horizontal frames have a single channel, and are strongly aligned by default.
31
+ * A horizontal frame typically has a single array (in which case, it's also 'square'),
32
+ * although it can have multiple arrays if all the arrays are continuous in time.
33
+ *
34
+ * - Vertical frames are strongly aligned and have on or more channels, but ONLY a single
35
+ * array per channel. Synnax requires that all frames written to the database are
36
+ * vertical.
37
+ *
38
+ * - Square frames are both horizontal and vertical. Only a frame with a single channel
39
+ * and array can be square.
40
+ */
41
+ export declare class Frame {
42
+ readonly columns: Keys | Names;
43
+ readonly series: Series[];
44
+ constructor(columnsOrData?: Params | CrudeFrame, arrays?: Series | Series[]);
45
+ /**
46
+ * @returns "key" if the frame columns are channel keys, "name" if the columns are
47
+ * channel names, and null if the frame has no columns.
48
+ */
49
+ get colType(): ColumnType;
50
+ /**
51
+ * @returns the channel keys if the frame is keyed by channel key, and throws an error
52
+ * otherwise.
53
+ */
54
+ get keys(): Keys;
55
+ /**
56
+ * @returns the unique channel keys if the frame is keyed by channel key, and throws an
57
+ * error otherwise.
58
+ */
59
+ get uniqueKeys(): Keys;
60
+ /**
61
+ * @returns the channel names if the frame is keyed by channel name, and throws an error
62
+ * otherwise.
63
+ */
64
+ get names(): Names;
65
+ /**
66
+ * @returns the unique channel names if the frame is keyed by channel name, and throws an
67
+ * otherwise.
68
+ */
69
+ get uniqueNames(): Names;
70
+ /**
71
+ * @returns the unique columns in the frame.
72
+ */
73
+ get uniqueColumns(): Keys | Names;
74
+ toPayload(): FramePayload;
75
+ /**
76
+ * @returns true if the frame is vertical. Vertical frames are strongly aligned and
77
+ * have on or more channels, but ONLY a single array per channel. Synnax requires
78
+ * that all frames written to the database are vertical.
79
+ */
80
+ get isVertical(): boolean;
81
+ /**
82
+ * @returns true if the frame is horizontal. Horizontal frames have a single channel,
83
+ * and are strongly aligned by default.A horizontal frame typically has a single array
84
+ * (in which case, it's also 'square'), although it can have multiple arrays if all
85
+ * the arrays are continuous in time.
86
+ */
87
+ get isHorizontal(): boolean;
88
+ /**
89
+ * @returns true if the frame is square. Square frames are both horizontal and vertical.
90
+ * Only a frame with a single channel and array can be square.
91
+ */
92
+ get isSquare(): boolean;
93
+ /**
94
+ * @returns true if the frame is weakly aligned. A frame is weakly aligned if it meets
95
+ * the time range occupied by all arrays of a particular channel is the same for all
96
+ * channels in the frame. This means that the arrays for a particular channel can have
97
+ * gaps betwen them.
98
+ */
99
+ get isWeaklyAligned(): boolean;
100
+ timeRange(col?: KeyOrName): TimeRange;
101
+ get timeRanges(): TimeRange[];
102
+ /**
103
+ * @returns lazy arrays matching the given channel key or name.
104
+ * @param key the channel key or name.
105
+ */
106
+ get(key: KeyOrName): Series[];
107
+ /**
108
+ * @returns a frame with the given channel keys or names.
109
+ * @param keys the channel keys or names.
110
+ */
111
+ get(keys: Keys | Names): Frame;
112
+ /**
113
+ * Pushes a set of typed arrays for the given channel onto the frame.
114
+ *
115
+ * @param key the channel key or name;
116
+ * @param v the typed arrays to push.
117
+ */
118
+ push(key: KeyOrName, ...v: Series[]): void;
119
+ /**
120
+ * Pushes the frame onto the current frame.
121
+ *
122
+ * @param frame - the frame to push.
123
+ */
124
+ push(frame: Frame): void;
125
+ /**
126
+ * @returns a shallow copy of this frame containing all typed arrays in the current frame and the
127
+ * provided frame.
128
+ */
129
+ concat(frame: Frame): Frame;
130
+ /**
131
+ * @returns true if the frame contains the provided channel key or name.
132
+ * @param channel the channel key or name to check.
133
+ */
134
+ has(channel: KeyOrName): boolean;
135
+ /**
136
+ * @returns a new frame containing the mapped output of the provided function.
137
+ * @param fn a function that takes a channel key and typed array and returns a
138
+ * boolean.
139
+ */
140
+ map(fn: (k: KeyOrName, arr: Series, i: number) => [KeyOrName, Series]): Frame;
141
+ /**
142
+ * Iterates over all typed arrays in the current frame.
143
+ *
144
+ * @param fn a function that takes a channel key and typed array.
145
+ */
146
+ forEach(fn: (k: KeyOrName, arr: Series, i: number) => void): void;
147
+ /**
148
+ * @returns a new frame containing all typed arrays in the current frame that pass
149
+ * the provided filter function.
150
+ * @param fn a function that takes a channel key and typed array and returns a boolean.
151
+ */
152
+ filter(fn: (k: KeyOrName, arr: Series, i: number) => boolean): Frame;
153
+ /** @returns the total number of bytes in the frame. */
154
+ get byteLength(): Size;
155
+ /** @returns the total number of samples in the frame. */
156
+ get length(): number;
157
+ }
158
+ export declare const series: z.ZodObject<{
159
+ timeRange: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodObject<{
160
+ start: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, import("@synnaxlabs/x").TimeStamp, Number>, z.ZodEffects<z.ZodNumber, import("@synnaxlabs/x").TimeStamp, number>, z.ZodType<import("@synnaxlabs/x").TimeStamp, z.ZodTypeDef, import("@synnaxlabs/x").TimeStamp>]>;
161
+ end: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, import("@synnaxlabs/x").TimeStamp, Number>, z.ZodEffects<z.ZodNumber, import("@synnaxlabs/x").TimeStamp, number>, z.ZodType<import("@synnaxlabs/x").TimeStamp, z.ZodTypeDef, import("@synnaxlabs/x").TimeStamp>]>;
162
+ }, "strip", z.ZodTypeAny, {
163
+ start: import("@synnaxlabs/x").TimeStamp;
164
+ end: import("@synnaxlabs/x").TimeStamp;
165
+ }, {
166
+ start: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
167
+ end: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
168
+ }>, TimeRange, {
169
+ start: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
170
+ end: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
171
+ }>, z.ZodType<TimeRange, z.ZodTypeDef, TimeRange>]>>;
172
+ alignment: z.ZodOptional<z.ZodNumber>;
173
+ dataType: z.ZodUnion<[z.ZodEffects<z.ZodString, DataType, string>, z.ZodType<DataType, z.ZodTypeDef, DataType>]>;
174
+ data: z.ZodEffects<z.ZodString, ArrayBuffer | SharedArrayBuffer, string>;
175
+ }, "strip", z.ZodTypeAny, {
176
+ dataType: DataType;
177
+ data: (ArrayBuffer | SharedArrayBuffer) & (ArrayBuffer | SharedArrayBuffer | undefined);
178
+ timeRange?: TimeRange | undefined;
179
+ alignment?: number | undefined;
180
+ }, {
181
+ dataType: (string | DataType) & (string | DataType | undefined);
182
+ data: string;
183
+ timeRange?: TimeRange | {
184
+ start: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
185
+ end: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
186
+ } | undefined;
187
+ alignment?: number | undefined;
188
+ }>;
189
+ export type SeriesPayload = z.infer<typeof series>;
190
+ export declare const frameZ: z.ZodObject<{
191
+ keys: z.ZodUnion<[z.ZodEffects<z.ZodNull, number[], null>, z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>>]>;
192
+ series: z.ZodUnion<[z.ZodEffects<z.ZodNull, {
193
+ dataType: DataType;
194
+ data: (ArrayBuffer | SharedArrayBuffer) & (ArrayBuffer | SharedArrayBuffer | undefined);
195
+ timeRange?: TimeRange | undefined;
196
+ alignment?: number | undefined;
197
+ }[], null>, z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
198
+ timeRange: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodObject<{
199
+ start: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, import("@synnaxlabs/x").TimeStamp, Number>, z.ZodEffects<z.ZodNumber, import("@synnaxlabs/x").TimeStamp, number>, z.ZodType<import("@synnaxlabs/x").TimeStamp, z.ZodTypeDef, import("@synnaxlabs/x").TimeStamp>]>;
200
+ end: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, import("@synnaxlabs/x").TimeStamp, Number>, z.ZodEffects<z.ZodNumber, import("@synnaxlabs/x").TimeStamp, number>, z.ZodType<import("@synnaxlabs/x").TimeStamp, z.ZodTypeDef, import("@synnaxlabs/x").TimeStamp>]>;
201
+ }, "strip", z.ZodTypeAny, {
202
+ start: import("@synnaxlabs/x").TimeStamp;
203
+ end: import("@synnaxlabs/x").TimeStamp;
204
+ }, {
205
+ start: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
206
+ end: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
207
+ }>, TimeRange, {
208
+ start: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
209
+ end: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
210
+ }>, z.ZodType<TimeRange, z.ZodTypeDef, TimeRange>]>>;
211
+ alignment: z.ZodOptional<z.ZodNumber>;
212
+ dataType: z.ZodUnion<[z.ZodEffects<z.ZodString, DataType, string>, z.ZodType<DataType, z.ZodTypeDef, DataType>]>;
213
+ data: z.ZodEffects<z.ZodString, ArrayBuffer | SharedArrayBuffer, string>;
214
+ }, "strip", z.ZodTypeAny, {
215
+ dataType: DataType;
216
+ data: (ArrayBuffer | SharedArrayBuffer) & (ArrayBuffer | SharedArrayBuffer | undefined);
217
+ timeRange?: TimeRange | undefined;
218
+ alignment?: number | undefined;
219
+ }, {
220
+ dataType: (string | DataType) & (string | DataType | undefined);
221
+ data: string;
222
+ timeRange?: TimeRange | {
223
+ start: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
224
+ end: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
225
+ } | undefined;
226
+ alignment?: number | undefined;
227
+ }>, "many">>>]>;
228
+ }, "strip", z.ZodTypeAny, {
229
+ keys: number[];
230
+ series: {
231
+ dataType: DataType;
232
+ data: (ArrayBuffer | SharedArrayBuffer) & (ArrayBuffer | SharedArrayBuffer | undefined);
233
+ timeRange?: TimeRange | undefined;
234
+ alignment?: number | undefined;
235
+ }[];
236
+ }, {
237
+ keys?: number[] | null | undefined;
238
+ series?: {
239
+ dataType: (string | DataType) & (string | DataType | undefined);
240
+ data: string;
241
+ timeRange?: TimeRange | {
242
+ start: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
243
+ end: (number | Number | import("@synnaxlabs/x").TimeStamp) & (number | Number | import("@synnaxlabs/x").TimeStamp | undefined);
244
+ } | undefined;
245
+ alignment?: number | undefined;
246
+ }[] | null | undefined;
247
+ }>;
248
+ export type FramePayload = z.infer<typeof frameZ>;
249
+ export declare const seriesFromPayload: (series: SeriesPayload) => Series;
250
+ export declare const seriesToPayload: (series: Series) => SeriesPayload;
251
+ export {};
@@ -0,0 +1 @@
1
+ export * as framer from '../framer/external';