@synnaxlabs/x 0.42.1 → 0.43.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 (296) hide show
  1. package/.turbo/turbo-build.log +93 -105
  2. package/.vscode/settings.json +4 -6
  3. package/README.md +1 -7
  4. package/dist/array.cjs +1 -0
  5. package/dist/array.js +7 -0
  6. package/dist/base-B5lQIJKc.js +38 -0
  7. package/dist/base-CTq-lhpU.cjs +1 -0
  8. package/dist/binary.cjs +1 -1
  9. package/dist/binary.js +1 -1
  10. package/dist/bounds.cjs +1 -1
  11. package/dist/bounds.js +2 -2
  12. package/dist/box.cjs +1 -1
  13. package/dist/box.js +1 -1
  14. package/dist/caseconv.cjs +1 -1
  15. package/dist/caseconv.js +2 -2
  16. package/dist/change.cjs +1 -1
  17. package/dist/change.js +10 -2
  18. package/dist/compare.cjs +1 -1
  19. package/dist/compare.js +1 -1
  20. package/dist/deep.cjs +1 -1
  21. package/dist/deep.js +92 -79
  22. package/dist/dimensions.cjs +1 -1
  23. package/dist/dimensions.js +41 -2
  24. package/dist/direction.cjs +1 -1
  25. package/dist/direction.js +1 -1
  26. package/dist/index-4GlOgZuh.js +99 -0
  27. package/dist/{direction-C-b6XTeU.cjs → index-B58dnYRu.cjs} +1 -1
  28. package/dist/index-BMGaoK93.cjs +1 -0
  29. package/dist/index-BTet04Hd.cjs +6 -0
  30. package/dist/{scale-DfJe9755.js → index-BUa-NXAX.js} +46 -46
  31. package/dist/{xy-D_LqxaGt.js → index-C-qYOegc.js} +62 -62
  32. package/dist/index-C07SBJhr.js +128 -0
  33. package/dist/{bounds-Bn5_l4Z3.js → index-C9EdKeu1.js} +77 -76
  34. package/dist/index-CM8ZDZ6s.cjs +1 -0
  35. package/dist/index-CV2JaHfw.cjs +1 -0
  36. package/dist/index-CeBvOwG8.cjs +3 -0
  37. package/dist/index-ClrGyGDp.js +205 -0
  38. package/dist/index-CqQXXeCI.cjs +1 -0
  39. package/dist/{location-C3aeu046.js → index-D6V-8SKw.js} +26 -26
  40. package/dist/index-DBGAIs_7.js +2492 -0
  41. package/dist/index-DEdq2tza.cjs +1 -0
  42. package/dist/index-DKMnHBGR.cjs +1 -0
  43. package/dist/index-Dql5FMcH.js +47 -0
  44. package/dist/{direction-BL0PhD1k.js → index-DxU1zwsd.js} +1 -1
  45. package/dist/index-WwMnwoLy.cjs +1 -0
  46. package/dist/index.cjs +5 -3
  47. package/dist/index.js +5372 -649
  48. package/dist/kv.cjs +1 -1
  49. package/dist/kv.js +45 -2
  50. package/dist/location.cjs +1 -1
  51. package/dist/location.js +1 -1
  52. package/dist/position.cjs +1 -1
  53. package/dist/position.js +83 -2
  54. package/dist/record.cjs +1 -1
  55. package/dist/record.js +8 -10
  56. package/dist/runtime.cjs +1 -1
  57. package/dist/runtime.js +27 -2
  58. package/dist/scale.cjs +1 -1
  59. package/dist/scale.js +1 -1
  60. package/dist/schemas-55Usj0Fg.js +3998 -0
  61. package/dist/schemas-DbXuI2Qr.cjs +27 -0
  62. package/dist/spatial.cjs +1 -1
  63. package/dist/spatial.js +25 -18
  64. package/dist/src/array/index.d.ts +2 -0
  65. package/dist/src/array/index.d.ts.map +1 -0
  66. package/dist/src/array/toArray.d.ts +19 -0
  67. package/dist/src/array/toArray.d.ts.map +1 -0
  68. package/dist/src/array/toArray.spec.d.ts +2 -0
  69. package/dist/src/array/toArray.spec.d.ts.map +1 -0
  70. package/dist/src/binary/codec.d.ts +8 -16
  71. package/dist/src/binary/codec.d.ts.map +1 -1
  72. package/dist/src/breaker/breaker.d.ts +6 -6
  73. package/dist/src/breaker/breaker.d.ts.map +1 -1
  74. package/dist/src/caseconv/caseconv.d.ts +1 -1
  75. package/dist/src/caseconv/caseconv.d.ts.map +1 -1
  76. package/dist/src/change/change.d.ts +3 -3
  77. package/dist/src/change/change.d.ts.map +1 -1
  78. package/dist/src/color/color.d.ts +63 -28
  79. package/dist/src/color/color.d.ts.map +1 -1
  80. package/dist/src/color/external.d.ts +0 -1
  81. package/dist/src/color/external.d.ts.map +1 -1
  82. package/dist/src/color/gradient.d.ts +9 -5
  83. package/dist/src/color/gradient.d.ts.map +1 -1
  84. package/dist/src/color/palette.d.ts +14 -6
  85. package/dist/src/color/palette.d.ts.map +1 -1
  86. package/dist/src/compare/compare.d.ts +4 -4
  87. package/dist/src/compare/compare.d.ts.map +1 -1
  88. package/dist/src/control/control.d.ts +32 -32
  89. package/dist/src/control/control.d.ts.map +1 -1
  90. package/dist/src/debounce/debounce.d.ts +1 -1
  91. package/dist/src/debounce/debounce.d.ts.map +1 -1
  92. package/dist/src/deep/delete.d.ts +1 -1
  93. package/dist/src/deep/delete.d.ts.map +1 -1
  94. package/dist/src/deep/difference.d.ts.map +1 -1
  95. package/dist/src/deep/equal.d.ts +4 -4
  96. package/dist/src/deep/equal.d.ts.map +1 -1
  97. package/dist/src/deep/merge.d.ts +1 -1
  98. package/dist/src/deep/merge.d.ts.map +1 -1
  99. package/dist/src/errors/errors.d.ts +62 -36
  100. package/dist/src/errors/errors.d.ts.map +1 -1
  101. package/dist/src/index.d.ts +4 -1
  102. package/dist/src/index.d.ts.map +1 -1
  103. package/dist/src/instance/index.d.ts +2 -0
  104. package/dist/src/instance/index.d.ts.map +1 -0
  105. package/dist/src/instance/matcher.d.ts +79 -0
  106. package/dist/src/instance/matcher.d.ts.map +1 -0
  107. package/dist/src/instance/matcher.spec.d.ts +2 -0
  108. package/dist/src/instance/matcher.spec.d.ts.map +1 -0
  109. package/dist/src/jsonrpc/jsonrpc.d.ts +40 -9
  110. package/dist/src/jsonrpc/jsonrpc.d.ts.map +1 -1
  111. package/dist/src/kv/types.d.ts +2 -2
  112. package/dist/src/kv/types.d.ts.map +1 -1
  113. package/dist/src/migrate/migrate.d.ts +5 -5
  114. package/dist/src/migrate/migrate.d.ts.map +1 -1
  115. package/dist/src/notation/notation.d.ts +1 -1
  116. package/dist/src/notation/notation.d.ts.map +1 -1
  117. package/dist/src/primitive/index.d.ts +2 -0
  118. package/dist/src/primitive/index.d.ts.map +1 -0
  119. package/dist/src/primitive/primitive.d.ts +39 -0
  120. package/dist/src/primitive/primitive.d.ts.map +1 -0
  121. package/dist/src/primitive/primitive.spec.d.ts +2 -0
  122. package/dist/src/primitive/primitive.spec.d.ts.map +1 -0
  123. package/dist/src/record.d.ts +2 -2
  124. package/dist/src/record.d.ts.map +1 -1
  125. package/dist/src/renderable.d.ts +1 -1
  126. package/dist/src/renderable.d.ts.map +1 -1
  127. package/dist/src/replace.d.ts.map +1 -1
  128. package/dist/src/runtime/detect.d.ts.map +1 -1
  129. package/dist/src/runtime/os.d.ts +1 -1
  130. package/dist/src/runtime/os.d.ts.map +1 -1
  131. package/dist/src/spatial/base.d.ts +10 -10
  132. package/dist/src/spatial/base.d.ts.map +1 -1
  133. package/dist/src/spatial/bounds/bounds.d.ts +82 -16
  134. package/dist/src/spatial/bounds/bounds.d.ts.map +1 -1
  135. package/dist/src/spatial/box/box.d.ts +7 -7
  136. package/dist/src/spatial/box/box.d.ts.map +1 -1
  137. package/dist/src/spatial/dimensions/dimensions.d.ts +5 -5
  138. package/dist/src/spatial/dimensions/dimensions.d.ts.map +1 -1
  139. package/dist/src/spatial/direction/direction.d.ts +1 -1
  140. package/dist/src/spatial/location/location.d.ts +4 -4
  141. package/dist/src/spatial/location/location.d.ts.map +1 -1
  142. package/dist/src/spatial/scale/scale.d.ts +11 -11
  143. package/dist/src/spatial/scale/scale.d.ts.map +1 -1
  144. package/dist/src/spatial/xy/xy.d.ts +5 -5
  145. package/dist/src/spatial/xy/xy.d.ts.map +1 -1
  146. package/dist/src/status/index.d.ts +2 -0
  147. package/dist/src/status/index.d.ts.map +1 -0
  148. package/dist/src/status/types.d.ts +11 -0
  149. package/dist/src/status/types.d.ts.map +1 -0
  150. package/dist/src/sync/index.d.ts.map +1 -1
  151. package/dist/src/sync/mutex.d.ts +0 -1
  152. package/dist/src/sync/mutex.d.ts.map +1 -1
  153. package/dist/src/telem/gl.d.ts +1 -1
  154. package/dist/src/telem/gl.d.ts.map +1 -1
  155. package/dist/src/telem/series.d.ts +468 -62
  156. package/dist/src/telem/series.d.ts.map +1 -1
  157. package/dist/src/telem/telem.d.ts +243 -53
  158. package/dist/src/telem/telem.d.ts.map +1 -1
  159. package/dist/src/uuid/index.d.ts +2 -0
  160. package/dist/src/uuid/index.d.ts.map +1 -0
  161. package/dist/src/uuid/uuid.d.ts +35 -0
  162. package/dist/src/uuid/uuid.d.ts.map +1 -0
  163. package/dist/src/uuid/uuid.spec.d.ts +2 -0
  164. package/dist/src/uuid/uuid.spec.d.ts.map +1 -0
  165. package/dist/src/zod/external.d.ts +1 -1
  166. package/dist/src/zod/external.d.ts.map +1 -1
  167. package/dist/src/zod/nullToUndefined.d.ts +3 -0
  168. package/dist/src/zod/nullToUndefined.d.ts.map +1 -0
  169. package/dist/src/zod/nullToUndefined.spec.d.ts +2 -0
  170. package/dist/src/zod/nullToUndefined.spec.d.ts.map +1 -0
  171. package/dist/src/zod/util.d.ts +2 -2
  172. package/dist/src/zod/util.d.ts.map +1 -1
  173. package/dist/telem.cjs +1 -1
  174. package/dist/telem.js +1 -1
  175. package/dist/xy.cjs +1 -1
  176. package/dist/xy.js +1 -1
  177. package/dist/zod.cjs +1 -1
  178. package/dist/zod.js +19 -2
  179. package/eslint.config.js +1 -1
  180. package/package.json +16 -14
  181. package/src/{toArray.ts → array/index.ts} +1 -5
  182. package/src/array/toArray.spec.ts +56 -0
  183. package/src/array/toArray.ts +28 -0
  184. package/src/binary/codec.spec.ts +201 -278
  185. package/src/binary/codec.ts +20 -76
  186. package/src/breaker/breaker.ts +3 -3
  187. package/src/caseconv/caseconv.ts +6 -4
  188. package/src/change/change.ts +2 -2
  189. package/src/color/color.spec.ts +121 -2
  190. package/src/color/color.ts +90 -54
  191. package/src/color/external.ts +0 -1
  192. package/src/color/gradient.ts +20 -28
  193. package/src/color/palette.ts +1 -1
  194. package/src/compare/compare.ts +5 -5
  195. package/src/control/control.ts +22 -19
  196. package/src/debounce/debounce.ts +1 -1
  197. package/src/deep/delete.ts +5 -4
  198. package/src/deep/difference.ts +6 -2
  199. package/src/deep/equal.spec.ts +1 -1
  200. package/src/deep/equal.ts +5 -5
  201. package/src/deep/merge.spec.ts +13 -1
  202. package/src/deep/merge.ts +16 -7
  203. package/src/deep/path.ts +1 -1
  204. package/src/errors/errors.ts +65 -44
  205. package/src/index.ts +4 -1
  206. package/src/instance/index.ts +10 -0
  207. package/src/instance/matcher.spec.ts +78 -0
  208. package/src/instance/matcher.ts +98 -0
  209. package/src/jsonrpc/jsonrpc.spec.ts +2 -1
  210. package/src/jsonrpc/jsonrpc.ts +36 -7
  211. package/src/kv/types.ts +1 -1
  212. package/src/migrate/migrate.spec.ts +1 -1
  213. package/src/migrate/migrate.ts +7 -7
  214. package/src/notation/notation.ts +1 -1
  215. package/src/primitive/index.ts +10 -0
  216. package/src/primitive/primitive.spec.ts +126 -0
  217. package/src/primitive/primitive.ts +82 -0
  218. package/src/record.ts +3 -5
  219. package/src/renderable.ts +1 -1
  220. package/src/replace.ts +9 -0
  221. package/src/runtime/detect.ts +0 -2
  222. package/src/runtime/os.ts +1 -1
  223. package/src/spatial/base.ts +1 -1
  224. package/src/spatial/bounds/bounds.spec.ts +20 -0
  225. package/src/spatial/bounds/bounds.ts +101 -18
  226. package/src/spatial/box/box.ts +1 -1
  227. package/src/spatial/dimensions/dimensions.ts +3 -3
  228. package/src/spatial/location/location.ts +1 -1
  229. package/src/spatial/scale/scale.ts +1 -1
  230. package/src/spatial/xy/xy.ts +1 -1
  231. package/src/status/index.ts +10 -0
  232. package/src/status/types.ts +22 -0
  233. package/src/sync/index.ts +9 -0
  234. package/src/sync/mutex.ts +9 -4
  235. package/src/telem/gl.ts +1 -1
  236. package/src/telem/series.spec.ts +735 -68
  237. package/src/telem/series.ts +536 -195
  238. package/src/telem/telem.spec.ts +60 -7
  239. package/src/telem/telem.ts +287 -95
  240. package/src/uuid/index.ts +10 -0
  241. package/src/uuid/uuid.spec.ts +82 -0
  242. package/src/uuid/uuid.ts +48 -0
  243. package/src/zod/external.ts +1 -1
  244. package/src/zod/nullToUndefined.spec.ts +31 -0
  245. package/src/zod/nullToUndefined.ts +23 -0
  246. package/src/zod/util.spec.ts +1 -1
  247. package/src/zod/util.ts +6 -6
  248. package/tsconfig.json +1 -1
  249. package/tsconfig.tsbuildinfo +1 -1
  250. package/vite.config.ts +1 -1
  251. package/dist/base-BAM2mqCy.cjs +0 -1
  252. package/dist/base-DFq0vvGn.js +0 -38
  253. package/dist/bounds-BQo7rvs9.cjs +0 -1
  254. package/dist/box-0YrQibkB.cjs +0 -1
  255. package/dist/box-Cc8IzcNo.js +0 -205
  256. package/dist/change-C-YELKx6.cjs +0 -1
  257. package/dist/change-DLl6DccR.js +0 -12
  258. package/dist/dimensions-CRgergMS.js +0 -43
  259. package/dist/dimensions-D2QGoNXO.cjs +0 -1
  260. package/dist/external-BPgtxa8d.js +0 -29
  261. package/dist/external-C-dNgNQw.cjs +0 -1
  262. package/dist/external-C8TFju8Q.js +0 -29
  263. package/dist/external-DWQITF5_.cjs +0 -1
  264. package/dist/external-DqPrWKvU.js +0 -47
  265. package/dist/external-uXk0Avrg.cjs +0 -1
  266. package/dist/index-BywOGO8U.js +0 -1074
  267. package/dist/index-CYYjI7Uf.cjs +0 -1
  268. package/dist/index-C_6NXBlg.cjs +0 -3
  269. package/dist/index-Dd8DLyMx.cjs +0 -1
  270. package/dist/index-DizUWH6z.js +0 -47
  271. package/dist/index-QGplUHuy.js +0 -98
  272. package/dist/location-BGl5Ddds.cjs +0 -1
  273. package/dist/position-Cai5-wi1.cjs +0 -1
  274. package/dist/position-DIglP1l2.js +0 -85
  275. package/dist/scale-BtZINJ-A.cjs +0 -1
  276. package/dist/series-B9JERcqi.js +0 -1977
  277. package/dist/series-DqJ6f97G.cjs +0 -11
  278. package/dist/spatial-BSWPzMkK.js +0 -11
  279. package/dist/spatial-DGpZ2sO3.cjs +0 -1
  280. package/dist/src/color/transformColorsToHex.d.ts +0 -6
  281. package/dist/src/color/transformColorsToHex.d.ts.map +0 -1
  282. package/dist/src/primitive.d.ts +0 -9
  283. package/dist/src/primitive.d.ts.map +0 -1
  284. package/dist/src/toArray.d.ts +0 -3
  285. package/dist/src/toArray.d.ts.map +0 -1
  286. package/dist/src/zod/integer.d.ts +0 -10
  287. package/dist/src/zod/integer.d.ts.map +0 -1
  288. package/dist/src/zod/integer.spec.d.ts +0 -2
  289. package/dist/src/zod/integer.spec.d.ts.map +0 -1
  290. package/dist/toArray.cjs +0 -1
  291. package/dist/toArray.js +0 -5
  292. package/dist/xy-B7065J2S.cjs +0 -1
  293. package/src/color/transformColorsToHex.ts +0 -30
  294. package/src/primitive.ts +0 -46
  295. package/src/zod/integer.spec.ts +0 -148
  296. package/src/zod/integer.ts +0 -38
@@ -8,363 +8,286 @@
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
10
  import { describe, expect, it } from "vitest";
11
- import { z } from "zod";
11
+ import { z } from "zod/v4";
12
12
 
13
13
  import { binary } from "@/binary";
14
- import { JSON_CODEC, MSGPACK_CODEC } from "@/binary/codec";
15
14
 
16
- const sampleSchema = z.object({
17
- channelKey: z.string(),
18
- timeStamp: z.number(),
19
- value: z.unknown(),
20
- });
15
+ describe("Codec", () => {
16
+ const sampleSchema = z.object({
17
+ channelKey: z.string(),
18
+ timeStamp: z.number(),
19
+ value: z.unknown(),
20
+ });
21
21
 
22
- [JSON_CODEC, MSGPACK_CODEC].forEach((codec) => {
23
- describe(`encoder ${codec.contentType}`, () => {
24
- it("should correctly encode and decode items", () => {
22
+ binary.ENCODERS.forEach((e) => {
23
+ describe(`encoder ${e.contentType}`, () => {
24
+ it("should correctly encode and decode items", () => {
25
+ const sample = {
26
+ channelKey: "test",
27
+ timeStamp: 123,
28
+ value: [1, 2, 3],
29
+ };
30
+ const encoded = e.encode(sample);
31
+ expect(e.decode(encoded, sampleSchema)).toEqual(sample);
32
+ });
33
+ });
34
+ });
35
+
36
+ describe("JSON", () => {
37
+ it("should correctly convert keys to snake case", () => {
25
38
  const sample = {
26
39
  channelKey: "test",
27
40
  timeStamp: 123,
28
- value: [1, 2, 3],
41
+ value: new Array([1, 2, 3]),
29
42
  };
30
- const encoded = codec.encode(sample);
31
- expect(codec.decode(encoded, sampleSchema)).toEqual(sample);
43
+ const encoded = binary.JSON_CODEC.encodeString(sample);
44
+ const parse = JSON.parse(encoded);
45
+ expect(parse.channel_key).toEqual("test");
32
46
  });
33
- });
34
- });
35
47
 
36
- describe("JSON", () => {
37
- it("should correctly convert keys to snake case", () => {
38
- const sample = {
39
- channelKey: "test",
40
- timeStamp: 123,
41
- value: new Array([1, 2, 3]),
42
- };
43
- const encoded = binary.JSON_CODEC.encodeString(sample);
44
- const parse = JSON.parse(encoded);
45
- expect(parse.channel_key).toEqual("test");
46
- });
47
- it("should correctly decode keys from snake case", () => {
48
- const sample = {
49
- channel_key: "test",
50
- time_stamp: 123,
51
- value: new Array([1, 2, 3]),
52
- };
53
- const encoded = JSON.stringify(sample);
54
- const decoded = binary.JSON_CODEC.decodeString(encoded, sampleSchema);
55
- expect(decoded.channelKey).toEqual("test");
48
+ it("should correctly decode keys from snake case", () => {
49
+ const sample = {
50
+ channel_key: "test",
51
+ time_stamp: 123,
52
+ value: new Array([1, 2, 3]),
53
+ };
54
+ const encoded = JSON.stringify(sample);
55
+ const decoded = binary.JSON_CODEC.decodeString(encoded, sampleSchema);
56
+ expect(decoded.channelKey).toEqual("test");
57
+ });
56
58
  });
57
- });
58
59
 
59
- describe("CSV", () => {
60
- it("should correctly decode CSV data with valid input", () => {
61
- const sample = `
60
+ describe("CSV", () => {
61
+ it("should correctly decode CSV data with valid input", () => {
62
+ const sample = `
62
63
  channelKey,timeStamp,value
63
64
  test,123,5
64
65
  test2,124,6
65
66
  `;
66
- const decoded = binary.CSV_CODEC.decodeString(sample);
67
- expect(decoded).toEqual({
68
- channelKey: ["test", "test2"],
69
- timeStamp: [123, 124],
70
- value: [5, 6],
67
+ const decoded = binary.CSV_CODEC.decodeString(sample);
68
+ expect(decoded).toEqual({
69
+ channelKey: ["test", "test2"],
70
+ timeStamp: [123, 124],
71
+ value: [5, 6],
72
+ });
71
73
  });
72
- });
73
74
 
74
- it("should handle empty CSV data", () => {
75
- const sample = `
75
+ it("should handle empty CSV data", () => {
76
+ const sample = `
76
77
  `;
77
- const decoded = binary.CSV_CODEC.decodeString(sample);
78
- expect(decoded).toEqual({});
79
- });
78
+ const decoded = binary.CSV_CODEC.decodeString(sample);
79
+ expect(decoded).toEqual({});
80
+ });
80
81
 
81
- it("should handle CSV with only headers", () => {
82
- const sample = `
82
+ it("should handle CSV with only headers", () => {
83
+ const sample = `
83
84
  channelKey,timeStamp,value
84
85
  `;
85
- const decoded = binary.CSV_CODEC.decodeString(sample);
86
- expect(decoded).toEqual({
87
- channelKey: [],
88
- timeStamp: [],
89
- value: [],
86
+ const decoded = binary.CSV_CODEC.decodeString(sample);
87
+ expect(decoded).toEqual({
88
+ channelKey: [],
89
+ timeStamp: [],
90
+ value: [],
91
+ });
90
92
  });
91
- });
92
93
 
93
- it("should handle CSV with missing values", () => {
94
- const sample = `
94
+ it("should handle CSV with missing values", () => {
95
+ const sample = `
95
96
  channelKey,timeStamp,value
96
97
  test,123,
97
98
  test2,124,6
98
99
  `;
99
- const decoded = binary.CSV_CODEC.decodeString(sample);
100
- expect(decoded).toEqual({
101
- channelKey: ["test", "test2"],
102
- timeStamp: [123, 124],
103
- value: [6],
100
+ const decoded = binary.CSV_CODEC.decodeString(sample);
101
+ expect(decoded).toEqual({
102
+ channelKey: ["test", "test2"],
103
+ timeStamp: [123, 124],
104
+ value: [6],
105
+ });
104
106
  });
105
- });
106
107
 
107
- it("should handle CSV with extra values", () => {
108
- const sample = `
108
+ it("should handle CSV with extra values", () => {
109
+ const sample = `
109
110
  channelKey,timeStamp,value
110
111
  test,123,5,extra
111
112
  test2,124,6
112
113
  `;
113
- const decoded = binary.CSV_CODEC.decodeString(sample);
114
- expect(decoded).toEqual({
115
- channelKey: ["test", "test2"],
116
- timeStamp: [123, 124],
117
- value: [5, 6],
114
+ const decoded = binary.CSV_CODEC.decodeString(sample);
115
+ expect(decoded).toEqual({
116
+ channelKey: ["test", "test2"],
117
+ timeStamp: [123, 124],
118
+ value: [5, 6],
119
+ });
118
120
  });
119
- });
120
121
 
121
- it("should handle CSV with different types of values", () => {
122
- const sample = `
122
+ it("should handle CSV with different types of values", () => {
123
+ const sample = `
123
124
  key,number,string
124
125
  test,123,"hello"
125
126
  test2,456,"world"
126
127
  `;
127
- const decoded = binary.CSV_CODEC.decodeString(sample);
128
- expect(decoded).toEqual({
129
- key: ["test", "test2"],
130
- number: [123, 456],
131
- string: ["hello", "world"],
128
+ const decoded = binary.CSV_CODEC.decodeString(sample);
129
+ expect(decoded).toEqual({
130
+ key: ["test", "test2"],
131
+ number: [123, 456],
132
+ string: ["hello", "world"],
133
+ });
132
134
  });
133
- });
134
135
 
135
- it("should handle CSV with spaces around values", () => {
136
- const sample = `
136
+ it("should handle CSV with spaces around values", () => {
137
+ const sample = `
137
138
  key, number , string
138
139
  test , 123 , "hello"
139
140
  test2 , 456 , "world"
140
141
  `;
141
- const decoded = binary.CSV_CODEC.decodeString(sample);
142
- expect(decoded).toEqual({
143
- key: ["test", "test2"],
144
- number: [123, 456],
145
- string: ["hello", "world"],
142
+ const decoded = binary.CSV_CODEC.decodeString(sample);
143
+ expect(decoded).toEqual({
144
+ key: ["test", "test2"],
145
+ number: [123, 456],
146
+ string: ["hello", "world"],
147
+ });
146
148
  });
147
- });
148
149
 
149
- it("should handle CSV with empty rows", () => {
150
- const sample = `
150
+ it("should handle CSV with empty rows", () => {
151
+ const sample = `
151
152
  key,number,string
152
153
  test,123,"hello"
153
154
  ,
154
155
  test2,456,"world"
155
156
  `;
156
- const decoded = binary.CSV_CODEC.decodeString(sample);
157
- expect(decoded).toEqual({
158
- key: ["test", "test2"],
159
- number: [123, 456],
160
- string: ["hello", "world"],
157
+ const decoded = binary.CSV_CODEC.decodeString(sample);
158
+ expect(decoded).toEqual({
159
+ key: ["test", "test2"],
160
+ number: [123, 456],
161
+ string: ["hello", "world"],
162
+ });
161
163
  });
162
- });
163
164
 
164
- it("should handle CSV with single column", () => {
165
- const sample = `
165
+ it("should handle CSV with single column", () => {
166
+ const sample = `
166
167
  key
167
168
  test
168
169
  test2
169
170
  `;
170
- const decoded = binary.CSV_CODEC.decodeString(sample);
171
- expect(decoded).toEqual({
172
- key: ["test", "test2"],
171
+ const decoded = binary.CSV_CODEC.decodeString(sample);
172
+ expect(decoded).toEqual({
173
+ key: ["test", "test2"],
174
+ });
173
175
  });
174
- });
175
-
176
- it("should correctly encode array of objects to CSV", () => {
177
- const sampleData = [
178
- { name: "John", age: 30, city: "New York" },
179
- { name: "Alice", age: 25, city: "Boston" },
180
- { name: "Bob", age: 40, city: "Chicago" },
181
- ];
182
-
183
- const encoded = binary.CSV_CODEC.encodeString(sampleData);
184
- expect(encoded).toBe(
185
- 'name,age,city\n"John",30,"New York"\n"Alice",25,"Boston"\n"Bob",40,"Chicago"',
186
- );
187
- });
188
176
 
189
- it("should handle objects with missing values", () => {
190
- const sampleData = [
191
- { name: "John", age: 30, city: "New York" },
192
- { name: "Alice", age: 25 },
193
- { name: "Bob", city: "Chicago" },
194
- ];
195
-
196
- const encoded = binary.CSV_CODEC.encodeString(sampleData);
197
- expect(encoded).toBe(
198
- 'name,age,city\n"John",30,"New York"\n"Alice",25,""\n"Bob","","Chicago"',
199
- );
200
- });
201
-
202
- it("should handle objects with null and undefined values", () => {
203
- const sampleData = [
204
- { name: "John", age: null, city: undefined },
205
- { name: "Alice", age: 25, city: null },
206
- ];
207
-
208
- const encoded = binary.CSV_CODEC.encodeString(sampleData);
209
- expect(encoded).toBe('name,age,city\n"John","",""\n"Alice",25,""');
210
- });
177
+ it("should correctly encode array of objects to CSV", () => {
178
+ const sampleData = [
179
+ { name: "John", age: 30, city: "New York" },
180
+ { name: "Alice", age: 25, city: "Boston" },
181
+ { name: "Bob", age: 40, city: "Chicago" },
182
+ ];
183
+
184
+ const encoded = binary.CSV_CODEC.encodeString(sampleData);
185
+ expect(encoded).toBe(
186
+ 'name,age,city\n"John",30,"New York"\n"Alice",25,"Boston"\n"Bob",40,"Chicago"',
187
+ );
188
+ });
211
189
 
212
- it("should handle different data types in objects", () => {
213
- const sampleData = [
214
- { name: "John", active: true, score: 98.5 },
215
- { name: "Alice", active: false, score: 92.3 },
216
- ];
190
+ it("should handle objects with missing values", () => {
191
+ const sampleData = [
192
+ { name: "John", age: 30, city: "New York" },
193
+ { name: "Alice", age: 25 },
194
+ { name: "Bob", city: "Chicago" },
195
+ ];
196
+
197
+ const encoded = binary.CSV_CODEC.encodeString(sampleData);
198
+ expect(encoded).toBe(
199
+ 'name,age,city\n"John",30,"New York"\n"Alice",25,""\n"Bob","","Chicago"',
200
+ );
201
+ });
217
202
 
218
- const encoded = binary.CSV_CODEC.encodeString(sampleData);
219
- expect(encoded).toBe('name,active,score\n"John",true,98.5\n"Alice",false,92.3');
220
- });
203
+ it("should handle objects with null and undefined values", () => {
204
+ const sampleData = [
205
+ { name: "John", age: null, city: undefined },
206
+ { name: "Alice", age: 25, city: null },
207
+ ];
221
208
 
222
- it("should throw error when encoding empty array", () => {
223
- const sampleData: any[] = [];
209
+ const encoded = binary.CSV_CODEC.encodeString(sampleData);
210
+ expect(encoded).toBe('name,age,city\n"John","",""\n"Alice",25,""');
211
+ });
224
212
 
225
- expect(() => {
226
- binary.CSV_CODEC.encodeString(sampleData);
227
- }).toThrow("Payload must be an array of objects");
228
- });
213
+ it("should handle different data types in objects", () => {
214
+ const sampleData = [
215
+ { name: "John", active: true, score: 98.5 },
216
+ { name: "Alice", active: false, score: 92.3 },
217
+ ];
229
218
 
230
- it("should throw error when encoding non-array data", () => {
231
- const sampleData = { name: "John", age: 30 };
219
+ const encoded = binary.CSV_CODEC.encodeString(sampleData);
220
+ expect(encoded).toBe('name,active,score\n"John",true,98.5\n"Alice",false,92.3');
221
+ });
232
222
 
233
- expect(() => {
234
- binary.CSV_CODEC.encodeString(sampleData);
235
- }).toThrow("Payload must be an array of objects");
236
- });
223
+ it("should throw error when encoding empty array", () => {
224
+ const sampleData: unknown[] = [];
237
225
 
238
- it("should round-trip encode and decode CSV data", () => {
239
- const sampleData = [
240
- { name: "John", age: 30, city: "New York" },
241
- { name: "Alice", age: 25, city: "Boston" },
242
- ];
226
+ expect(() => {
227
+ binary.CSV_CODEC.encodeString(sampleData);
228
+ }).toThrow("Payload must be an array of objects");
229
+ });
243
230
 
244
- const encoded = binary.CSV_CODEC.encode(sampleData);
245
- const decoded = binary.CSV_CODEC.decode(encoded);
231
+ it("should throw error when encoding non-array data", () => {
232
+ const sampleData = { name: "John", age: 30 };
246
233
 
247
- expect(decoded).toEqual({
248
- name: ["John", "Alice"],
249
- age: [30, 25],
250
- city: ["New York", "Boston"],
234
+ expect(() => {
235
+ binary.CSV_CODEC.encodeString(sampleData);
236
+ }).toThrow("Payload must be an array of objects");
251
237
  });
252
- });
253
- });
254
238
 
255
- describe("MsgPack", () => {
256
- it("should correctly convert keys to snake case", () => {
257
- const sample = {
258
- channelKey: "test",
259
- timeStamp: 123,
260
- value: [1, 2, 3],
261
- };
262
- const encoded = binary.MSGPACK_CODEC.encode(sample);
263
- const decoded = binary.MSGPACK_CODEC.decode(encoded);
264
- expect(decoded).toEqual(sample);
265
- });
239
+ it("should round-trip encode and decode CSV data", () => {
240
+ const sampleData = [
241
+ { name: "John", age: 30, city: "New York" },
242
+ { name: "Alice", age: 25, city: "Boston" },
243
+ ];
266
244
 
267
- it("should correctly validate with schema", () => {
268
- const sample = {
269
- channelKey: "test",
270
- timeStamp: 123,
271
- value: [1, 2, 3],
272
- };
273
- const encoded = binary.MSGPACK_CODEC.encode(sample);
274
- const decoded = binary.MSGPACK_CODEC.decode(encoded, sampleSchema);
275
- expect(decoded).toEqual(sample);
276
- });
277
-
278
- it("should handle complex nested objects", () => {
279
- const sample = {
280
- channelKey: "test",
281
- timeStamp: 123,
282
- nestedObject: {
283
- innerKey: "value",
284
- numberArray: [1, 2, 3],
285
- deepNesting: {
286
- anotherKey: true,
287
- },
288
- },
289
- };
290
- const encoded = binary.MSGPACK_CODEC.encode(sample);
291
- const decoded = binary.MSGPACK_CODEC.decode(encoded);
292
- expect(decoded).toEqual(sample);
293
- });
245
+ const encoded = binary.CSV_CODEC.encode(sampleData);
246
+ const decoded = binary.CSV_CODEC.decode(encoded);
294
247
 
295
- it("should handle binary data", () => {
296
- const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
297
- const sample = {
298
- channelKey: "binary-test",
299
- timeStamp: 456,
300
- value: binaryData,
301
- };
302
- const encoded = binary.MSGPACK_CODEC.encode(sample);
303
- const decoded = binary.MSGPACK_CODEC.decode<typeof sampleSchema>(encoded);
304
-
305
- // Check that the structure is preserved
306
- expect(decoded.channelKey).toEqual(sample.channelKey);
307
- expect(decoded.timeStamp).toEqual(sample.timeStamp);
308
-
309
- // Verify that binary data is handled properly
310
- // Note: The exact format might depend on msgpack implementation
311
- expect(
312
- Array.isArray(decoded.value) || ArrayBuffer.isView(decoded.value),
313
- ).toBeTruthy();
314
- });
315
-
316
- class CustomValueEncoder {
317
- readonly encodeValue = true;
318
-
319
- value = "cat";
320
- }
321
-
322
- it("should correctly encode and decode custom value", () => {
323
- const sample = {
324
- channelKey: "test",
325
- timeStamp: 123,
326
- value: new CustomValueEncoder(),
327
- };
328
- const encoded = binary.MSGPACK_CODEC.encode(sample);
329
- const decoded = binary.MSGPACK_CODEC.decode(encoded, sampleSchema);
330
- expect(decoded).toEqual({ ...sample, value: "cat" });
248
+ expect(decoded).toEqual({
249
+ name: ["John", "Alice"],
250
+ age: [30, 25],
251
+ city: ["New York", "Boston"],
252
+ });
253
+ });
331
254
  });
332
- });
333
255
 
334
- describe("TextCodec", () => {
335
- it("should correctly encode and decode text", () => {
336
- const sampleText = "Hello, world!";
337
- const encoded = binary.TEXT_CODEC.encode(sampleText);
338
- const decoded = binary.TEXT_CODEC.decode(encoded);
339
- expect(decoded).toEqual(sampleText);
340
- });
256
+ describe("Text", () => {
257
+ it("should correctly encode and decode text", () => {
258
+ const sampleText = "Hello, world!";
259
+ const encoded = binary.TEXT_CODEC.encode(sampleText);
260
+ const decoded = binary.TEXT_CODEC.decode(encoded);
261
+ expect(decoded).toEqual(sampleText);
262
+ });
341
263
 
342
- it("should handle empty strings", () => {
343
- const sampleText = "";
344
- const encoded = binary.TEXT_CODEC.encode(sampleText);
345
- const decoded = binary.TEXT_CODEC.decode(encoded);
346
- expect(decoded).toEqual(sampleText);
347
- });
264
+ it("should handle empty strings", () => {
265
+ const sampleText = "";
266
+ const encoded = binary.TEXT_CODEC.encode(sampleText);
267
+ const decoded = binary.TEXT_CODEC.decode(encoded);
268
+ expect(decoded).toEqual(sampleText);
269
+ });
348
270
 
349
- it("should validate text with schema", () => {
350
- const textSchema = z.string();
351
- const sampleText = "Validation test";
352
- const encoded = binary.TEXT_CODEC.encode(sampleText);
353
- const decoded = binary.TEXT_CODEC.decode(encoded, textSchema);
354
- expect(decoded).toEqual(sampleText);
355
- });
271
+ it("should validate text with schema", () => {
272
+ const textSchema = z.string();
273
+ const sampleText = "Validation test";
274
+ const encoded = binary.TEXT_CODEC.encode(sampleText);
275
+ const decoded = binary.TEXT_CODEC.decode(encoded, textSchema);
276
+ expect(decoded).toEqual(sampleText);
277
+ });
356
278
 
357
- it("should handle special characters", () => {
358
- const sampleText = "Special characters: äöü!@#$%^&*()_+";
359
- const encoded = binary.TEXT_CODEC.encode(sampleText);
360
- const decoded = binary.TEXT_CODEC.decode(encoded);
361
- expect(decoded).toEqual(sampleText);
362
- });
279
+ it("should handle special characters", () => {
280
+ const sampleText = "Special characters: äöü!@#$%^&*()_+";
281
+ const encoded = binary.TEXT_CODEC.encode(sampleText);
282
+ const decoded = binary.TEXT_CODEC.decode(encoded);
283
+ expect(decoded).toEqual(sampleText);
284
+ });
363
285
 
364
- it("should handle multi-line text", () => {
365
- const sampleText = "Line 1\nLine 2\nLine 3";
366
- const encoded = binary.TEXT_CODEC.encode(sampleText);
367
- const decoded = binary.TEXT_CODEC.decode(encoded);
368
- expect(decoded).toEqual(sampleText);
286
+ it("should handle multi-line text", () => {
287
+ const sampleText = "Line 1\nLine 2\nLine 3";
288
+ const encoded = binary.TEXT_CODEC.encode(sampleText);
289
+ const decoded = binary.TEXT_CODEC.decode(encoded);
290
+ expect(decoded).toEqual(sampleText);
291
+ });
369
292
  });
370
293
  });