@synnaxlabs/x 0.44.2 → 0.44.4

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 (131) hide show
  1. package/.turbo/turbo-build.log +35 -39
  2. package/dist/base-BLNViP3D.cjs +1 -0
  3. package/dist/{base-DFq0vvGn.js → base-BORMP3mH.js} +14 -11
  4. package/dist/bounds-BQqppNFf.js +186 -0
  5. package/dist/bounds-BXbqBINt.cjs +1 -0
  6. package/dist/bounds.cjs +1 -1
  7. package/dist/bounds.js +1 -1
  8. package/dist/{box-CO_2_DGG.js → box-DRH5SOaY.js} +67 -73
  9. package/dist/box-qgxWXNhm.cjs +1 -0
  10. package/dist/box.cjs +1 -1
  11. package/dist/box.js +1 -1
  12. package/dist/deep.cjs +1 -1
  13. package/dist/deep.js +1 -1
  14. package/dist/{dimensions-CRgergMS.js → dimensions-RaRkesPq.js} +1 -1
  15. package/dist/{dimensions-D2QGoNXO.cjs → dimensions-qY12pyfC.cjs} +1 -1
  16. package/dist/dimensions.cjs +1 -1
  17. package/dist/dimensions.js +1 -1
  18. package/dist/direction-DKdfJwj7.js +19 -0
  19. package/dist/direction-XCdrc4is.cjs +1 -0
  20. package/dist/direction.cjs +1 -1
  21. package/dist/direction.js +1 -1
  22. package/dist/{external-Birv9jaY.js → external-BM_NS5yM.js} +6 -6
  23. package/dist/external-E3ErJeeM.cjs +1 -0
  24. package/dist/index.cjs +3 -3
  25. package/dist/index.js +244 -240
  26. package/dist/{location-Ar5y2DX2.js → location-CGLioInQ.js} +16 -21
  27. package/dist/location-DJ_K4SlP.cjs +1 -0
  28. package/dist/location.cjs +1 -1
  29. package/dist/location.js +1 -1
  30. package/dist/{path-DVFrKaNI.js → path-Blh4wJuA.js} +24 -21
  31. package/dist/path-CPSfCjde.cjs +1 -0
  32. package/dist/record-BwjIgrpU.cjs +1 -0
  33. package/dist/record-tSFQKmdG.js +19 -0
  34. package/dist/record.cjs +1 -1
  35. package/dist/record.js +1 -1
  36. package/dist/{scale-C6qKDbRb.cjs → scale-76Azh2EE.cjs} +1 -1
  37. package/dist/{scale-EWNUk-bn.js → scale-BhIvACdB.js} +4 -4
  38. package/dist/scale.cjs +1 -1
  39. package/dist/scale.js +1 -1
  40. package/dist/{series-EA1uaEDj.js → series-kgnLXSDr.js} +622 -489
  41. package/dist/series-tAhThbnz.cjs +6 -0
  42. package/dist/{spatial-DGpZ2sO3.cjs → spatial-BsGadoUr.cjs} +1 -1
  43. package/dist/{spatial-BSWPzMkK.js → spatial-QY891r0E.js} +1 -1
  44. package/dist/spatial.cjs +1 -1
  45. package/dist/spatial.js +14 -16
  46. package/dist/src/breaker/breaker.d.ts +2 -1
  47. package/dist/src/breaker/breaker.d.ts.map +1 -1
  48. package/dist/src/deep/path.d.ts.map +1 -1
  49. package/dist/src/id/id.d.ts +3 -1
  50. package/dist/src/id/id.d.ts.map +1 -1
  51. package/dist/src/math/math.d.ts +2 -1
  52. package/dist/src/math/math.d.ts.map +1 -1
  53. package/dist/src/record/record.d.ts +18 -0
  54. package/dist/src/record/record.d.ts.map +1 -1
  55. package/dist/src/spatial/base.d.ts +12 -0
  56. package/dist/src/spatial/base.d.ts.map +1 -1
  57. package/dist/src/spatial/direction/direction.d.ts +5 -1
  58. package/dist/src/spatial/direction/direction.d.ts.map +1 -1
  59. package/dist/src/spatial/external.d.ts +0 -1
  60. package/dist/src/spatial/external.d.ts.map +1 -1
  61. package/dist/src/spatial/xy/xy.d.ts +3 -0
  62. package/dist/src/spatial/xy/xy.d.ts.map +1 -1
  63. package/dist/src/status/status.d.ts +1 -0
  64. package/dist/src/status/status.d.ts.map +1 -1
  65. package/dist/src/strings/strings.d.ts +1 -1
  66. package/dist/src/strings/strings.d.ts.map +1 -1
  67. package/dist/src/telem/series.d.ts +7 -0
  68. package/dist/src/telem/series.d.ts.map +1 -1
  69. package/dist/src/telem/telem.d.ts +86 -1
  70. package/dist/src/telem/telem.d.ts.map +1 -1
  71. package/dist/src/zod/util.d.ts.map +1 -1
  72. package/dist/telem.cjs +1 -1
  73. package/dist/telem.js +1 -1
  74. package/dist/xy-BKIJiLu_.cjs +1 -0
  75. package/dist/{xy-C_-hb3Q2.js → xy-CBuhMaIo.js} +41 -31
  76. package/dist/xy.cjs +1 -1
  77. package/dist/xy.js +1 -1
  78. package/dist/zod.cjs +1 -1
  79. package/dist/zod.js +1 -1
  80. package/package.json +3 -8
  81. package/src/breaker/breaker.ts +4 -0
  82. package/src/deep/path.spec.ts +14 -0
  83. package/src/deep/path.ts +9 -2
  84. package/src/id/id.ts +8 -4
  85. package/src/math/math.spec.ts +20 -0
  86. package/src/math/math.ts +32 -29
  87. package/src/record/record.spec.ts +31 -0
  88. package/src/record/record.ts +23 -0
  89. package/src/spatial/base.ts +4 -0
  90. package/src/spatial/bounds/bounds.ts +1 -1
  91. package/src/spatial/direction/direction.spec.ts +35 -1
  92. package/src/spatial/direction/direction.ts +12 -0
  93. package/src/spatial/external.ts +0 -1
  94. package/src/spatial/xy/xy.spec.ts +124 -7
  95. package/src/spatial/xy/xy.ts +15 -2
  96. package/src/status/status.ts +11 -0
  97. package/src/strings/strings.spec.ts +3 -0
  98. package/src/strings/strings.ts +2 -1
  99. package/src/telem/series.spec.ts +543 -2
  100. package/src/telem/series.ts +28 -9
  101. package/src/telem/telem.spec.ts +606 -0
  102. package/src/telem/telem.ts +143 -5
  103. package/src/zod/util.ts +5 -3
  104. package/tsconfig.tsbuildinfo +1 -1
  105. package/vite.config.ts +0 -1
  106. package/dist/base-BAM2mqCy.cjs +0 -1
  107. package/dist/bounds-D6e9xoHt.cjs +0 -1
  108. package/dist/bounds-Dj9nG39I.js +0 -174
  109. package/dist/box-Cxki783Y.cjs +0 -1
  110. package/dist/direction-386XDm2w.cjs +0 -1
  111. package/dist/direction-8etxfKaR.js +0 -17
  112. package/dist/external-DsmsSN1Y.cjs +0 -1
  113. package/dist/location-DZi8ftXp.cjs +0 -1
  114. package/dist/path-BeMr8xWN.cjs +0 -1
  115. package/dist/position-DSy2hONH.cjs +0 -1
  116. package/dist/position-PQ6op54I.js +0 -85
  117. package/dist/position.cjs +0 -1
  118. package/dist/position.js +0 -4
  119. package/dist/record-CAcQ5PNX.js +0 -14
  120. package/dist/record-YvCh7bzB.cjs +0 -1
  121. package/dist/series-CcA_WjbJ.cjs +0 -6
  122. package/dist/src/spatial/position/index.d.ts +0 -2
  123. package/dist/src/spatial/position/index.d.ts.map +0 -1
  124. package/dist/src/spatial/position/position.d.ts +0 -20
  125. package/dist/src/spatial/position/position.d.ts.map +0 -1
  126. package/dist/src/spatial/position/position.spec.d.ts +0 -2
  127. package/dist/src/spatial/position/position.spec.d.ts.map +0 -1
  128. package/dist/xy-CUE3QDNn.cjs +0 -1
  129. package/src/spatial/position/index.ts +0 -10
  130. package/src/spatial/position/position.spec.ts +0 -211
  131. package/src/spatial/position/position.ts +0 -157
@@ -326,7 +326,7 @@ export class TimeStamp
326
326
  * TimeSpan.
327
327
  */
328
328
  add(span: CrudeTimeSpan): TimeStamp {
329
- return new TimeStamp(this.valueOf() + BigInt(span.valueOf()));
329
+ return new TimeStamp(math.add(this.valueOf(), new TimeSpan(span).valueOf()));
330
330
  }
331
331
 
332
332
  /**
@@ -337,7 +337,7 @@ export class TimeStamp
337
337
  * TimeSpan.
338
338
  */
339
339
  sub(span: CrudeTimeSpan): TimeStamp {
340
- return new TimeStamp(this.valueOf() - BigInt(span.valueOf()));
340
+ return new TimeStamp(math.sub(this.valueOf(), new TimeSpan(span).valueOf()));
341
341
  }
342
342
 
343
343
  /**
@@ -820,7 +820,17 @@ export class TimeSpan
820
820
  * @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
821
821
  */
822
822
  mult(value: number): TimeSpan {
823
- return new TimeSpan(this.valueOf() * BigInt(value));
823
+ return new TimeSpan(math.mult(this.valueOf(), value));
824
+ }
825
+
826
+ /**
827
+ * Divides the TimeSpan by a scalar value.
828
+ *
829
+ * @param value - The scalar value to divide by.
830
+ * @returns A new TimeSpan that is this TimeSpan divided by the provided value.
831
+ */
832
+ div(value: number): TimeSpan {
833
+ return new TimeSpan(math.div(this.valueOf(), value));
824
834
  }
825
835
 
826
836
  /** @returns the decimal number of days in the TimeSpan. */
@@ -999,7 +1009,10 @@ export class TimeSpan
999
1009
  z.object({ value: z.bigint() }).transform((v) => new TimeSpan(v.value)),
1000
1010
  z.string().transform((n) => new TimeSpan(BigInt(n))),
1001
1011
  z.number().transform((n) => new TimeSpan(n)),
1012
+ z.bigint().transform((n) => new TimeSpan(n)),
1002
1013
  z.instanceof(TimeSpan),
1014
+ z.instanceof(TimeStamp).transform((t) => new TimeSpan(t)),
1015
+ z.custom<Rate>((r) => r instanceof Rate).transform((r) => new TimeSpan(r)),
1003
1016
  ]);
1004
1017
  }
1005
1018
 
@@ -1073,6 +1086,46 @@ export class Rate
1073
1086
  return this.span(size.valueOf() / density.valueOf());
1074
1087
  }
1075
1088
 
1089
+ /**
1090
+ * Adds another Rate to this Rate.
1091
+ *
1092
+ * @param other - The Rate to add.
1093
+ * @returns A new Rate representing the sum of the two rates.
1094
+ */
1095
+ add(other: CrudeRate): Rate {
1096
+ return new Rate(math.add(this.valueOf(), other.valueOf()));
1097
+ }
1098
+
1099
+ /**
1100
+ * Subtracts another Rate from this Rate.
1101
+ *
1102
+ * @param other - The Rate to subtract.
1103
+ * @returns A new Rate representing the difference of the two rates.
1104
+ */
1105
+ sub(other: CrudeRate): Rate {
1106
+ return new Rate(math.sub(this.valueOf(), other.valueOf()));
1107
+ }
1108
+
1109
+ /**
1110
+ * Multiplies this Rate by a scalar value.
1111
+ *
1112
+ * @param value - The scalar value to multiply by.
1113
+ * @returns A new Rate representing this Rate multiplied by the value.
1114
+ */
1115
+ mult(value: number): Rate {
1116
+ return new Rate(math.mult(this.valueOf(), value));
1117
+ }
1118
+
1119
+ /**
1120
+ * Divides this Rate by a scalar value.
1121
+ *
1122
+ * @param value - The scalar value to divide by.
1123
+ * @returns A new Rate representing this Rate divided by the value.
1124
+ */
1125
+ div(value: number): Rate {
1126
+ return new Rate(math.div(this.valueOf(), value));
1127
+ }
1128
+
1076
1129
  /**
1077
1130
  * Creates a Rate representing the given number of Hz.
1078
1131
  *
@@ -1136,6 +1189,46 @@ export class Density
1136
1189
  return new Size(sampleCount * this.valueOf());
1137
1190
  }
1138
1191
 
1192
+ /**
1193
+ * Adds another Density to this Density.
1194
+ *
1195
+ * @param other - The Density to add.
1196
+ * @returns A new Density representing the sum of the two densities.
1197
+ */
1198
+ add(other: CrudeDensity): Density {
1199
+ return new Density(math.add(this.valueOf(), other.valueOf()));
1200
+ }
1201
+
1202
+ /**
1203
+ * Subtracts another Density from this Density.
1204
+ *
1205
+ * @param other - The Density to subtract.
1206
+ * @returns A new Density representing the difference of the two densities.
1207
+ */
1208
+ sub(other: CrudeDensity): Density {
1209
+ return new Density(math.sub(this.valueOf(), other.valueOf()));
1210
+ }
1211
+
1212
+ /**
1213
+ * Multiplies this Density by a scalar value.
1214
+ *
1215
+ * @param value - The scalar value to multiply by.
1216
+ * @returns A new Density representing this Density multiplied by the value.
1217
+ */
1218
+ mult(value: number): Density {
1219
+ return new Density(math.mult(this.valueOf(), value));
1220
+ }
1221
+
1222
+ /**
1223
+ * Divides this Density by a scalar value.
1224
+ *
1225
+ * @param value - The scalar value to divide by.
1226
+ * @returns A new Density representing this Density divided by the value.
1227
+ */
1228
+ div(value: number): Density {
1229
+ return new Density(math.div(this.valueOf(), value));
1230
+ }
1231
+
1139
1232
  /** Unknown/Invalid Density. */
1140
1233
  static readonly UNKNOWN = new Density(0);
1141
1234
  /** 128 bits per value. */
@@ -1407,6 +1500,31 @@ export class TimeRange implements primitive.Stringer {
1407
1500
  static sort(a: TimeRange, b: TimeRange): number {
1408
1501
  return TimeStamp.sort(a.start, b.start) || TimeStamp.sort(a.end, b.end);
1409
1502
  }
1503
+
1504
+ /**
1505
+ * Simplify takes the list of `TimeRange`s, makes all of them valid, sorts them, and
1506
+ * merges any overlapping ranges.
1507
+ *
1508
+ * @param ranges - The list of `TimeRange`s to simplify.
1509
+ * @returns A list of simplified `TimeRange`s.
1510
+ */
1511
+ static simplify(ranges: TimeRange[]): TimeRange[] {
1512
+ return ranges
1513
+ .map((r) => r.makeValid())
1514
+ .sort((a, b) => TimeRange.sort(a, b))
1515
+ .reduce<TimeRange[]>((simplified, range) => {
1516
+ if (range.isZero) return simplified;
1517
+ if (simplified.length === 0) {
1518
+ simplified.push(range);
1519
+ return simplified;
1520
+ }
1521
+ const last = simplified[simplified.length - 1];
1522
+ if (last.overlapsWith(range) || last.end.equals(range.start))
1523
+ last.end = TimeStamp.max(last.end, range.end);
1524
+ else simplified.push(range);
1525
+ return simplified;
1526
+ }, []);
1527
+ }
1410
1528
  }
1411
1529
 
1412
1530
  /** DataType is a string that represents a data type. */
@@ -1712,12 +1830,32 @@ export class Size
1712
1830
 
1713
1831
  /** @returns a new Size representing the sum of the two Sizes. */
1714
1832
  add(other: CrudeSize): Size {
1715
- return Size.bytes(this.valueOf() + other.valueOf());
1833
+ return new Size(math.add(this.valueOf(), other.valueOf()));
1716
1834
  }
1717
1835
 
1718
1836
  /** @returns a new Size representing the difference of the two Sizes. */
1719
1837
  sub(other: CrudeSize): Size {
1720
- return Size.bytes(this.valueOf() - other.valueOf());
1838
+ return new Size(math.sub(this.valueOf(), other.valueOf()));
1839
+ }
1840
+
1841
+ /**
1842
+ * Multiplies this Size by a scalar value.
1843
+ *
1844
+ * @param value - The scalar value to multiply by.
1845
+ * @returns A new Size representing this Size multiplied by the value.
1846
+ */
1847
+ mult(value: number): Size {
1848
+ return new Size(math.mult(this.valueOf(), value));
1849
+ }
1850
+
1851
+ /**
1852
+ * Divides this Size by a scalar value.
1853
+ *
1854
+ * @param value - The scalar value to divide by.
1855
+ * @returns A new Size representing this Size divided by the value.
1856
+ */
1857
+ div(value: number): Size {
1858
+ return new Size(math.div(this.valueOf(), value));
1721
1859
  }
1722
1860
 
1723
1861
  /** @returns a new Size representing the truncated value of the Size. */
package/src/zod/util.ts CHANGED
@@ -38,9 +38,11 @@ export const getFieldSchema: deep.TypedGet<z.ZodType, z.ZodType> = ((
38
38
  schema: z.ZodType,
39
39
  path: string,
40
40
  options?: Omit<deep.GetOptions, "getter">,
41
- ): z.ZodType | null =>
42
- deep.get<z.ZodType, z.ZodType>(
41
+ ): z.ZodType | null => {
42
+ if (path === "") return schema;
43
+ return deep.get<z.ZodType, z.ZodType>(
43
44
  sourceTypeGetter(schema, "shape") as unknown as z.ZodObject<z.ZodRawShape>,
44
45
  getFieldSchemaPath(path),
45
46
  { ...options, getter: sourceTypeGetter } as deep.GetOptions<boolean | undefined>,
46
- )) as deep.TypedGet<z.ZodType, z.ZodType>;
47
+ );
48
+ }) as deep.TypedGet<z.ZodType, z.ZodType>;