@synnaxlabs/x 0.13.0 → 0.14.1

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @synnaxlabs/x@0.13.0 build /home/runner/work/synnax/synnax/x/ts
2
+ > @synnaxlabs/x@0.14.1 build /home/runner/work/synnax/synnax/x/ts
3
3
  > tsc --noEmit && vite build
4
4
 
5
5
  vite v5.1.2 building for production...
@@ -10,8 +10,8 @@ rendering chunks...
10
10
  
11
11
  [vite:dts] Start generate declaration files...
12
12
  computing gzip size...
13
- dist/x.js 299.72 kB │ gzip: 56.93 kB │ map: 617.77 kB
14
- [vite:dts] Declaration files built in 2906ms.
13
+ dist/x.js 209.89 kB │ gzip: 49.04 kB │ map: 632.82 kB
14
+ [vite:dts] Declaration files built in 3265ms.
15
15
  
16
- dist/x.cjs 300.61 kB │ gzip: 57.08 kB │ map: 617.89 kB
17
- ✓ built in 3.78s
16
+ dist/x.cjs 137.61 kB │ gzip: 39.21 kB │ map: 612.53 kB
17
+ ✓ built in 4.16s
@@ -1,19 +1,4 @@
1
1
  import { type ZodSchema, type z } from "zod";
2
- /**
3
- * CustomTypeEncoder is an interface for a class that needs to transform its
4
- * value before encoding.
5
- */
6
- interface CustomTypeEncoder {
7
- /** The Class the custom encoder is set for */
8
- Class: Function;
9
- /**
10
- * The function that transforms the value before encoding;
11
- *
12
- * @param instance - The instance of the class to transform.
13
- * @returns The transformed value.
14
- */
15
- write: <P>(instance: P) => unknown;
16
- }
17
2
  /**
18
3
  * EncoderDecoder is an entity that encodes and decodes messages to and from a
19
4
  * binary format.
@@ -36,24 +21,19 @@ export interface EncoderDecoder {
36
21
  */
37
22
  decode: <P>(data: Uint8Array | ArrayBuffer, schema?: ZodSchema<P>) => P;
38
23
  }
39
- interface StaticEncoderDecoder {
40
- registerCustomType: (encoder: CustomTypeEncoder) => void;
41
- }
42
24
  /** MsgpackEncoderDecoder is a msgpack implementation of EncoderDecoder. */
43
25
  export declare class MsgpackEncoderDecoder implements EncoderDecoder {
44
26
  contentType: string;
45
27
  encode(payload: unknown): ArrayBuffer;
46
28
  decode<P extends z.ZodTypeAny>(data: Uint8Array | ArrayBuffer, schema?: P): z.output<P>;
47
- static registerCustomType(encoder: CustomTypeEncoder): void;
48
29
  }
49
30
  /** JSONEncoderDecoder is a JSON implementation of EncoderDecoder. */
50
31
  export declare class JSONEncoderDecoder implements EncoderDecoder {
51
32
  contentType: string;
33
+ readonly decoder: TextDecoder;
34
+ constructor();
52
35
  encode(payload: unknown): ArrayBuffer;
53
36
  decode<P extends z.ZodTypeAny>(data: Uint8Array | ArrayBuffer, schema?: P): z.output<P>;
54
37
  static registerCustomType(): void;
55
38
  }
56
39
  export declare const ENCODERS: EncoderDecoder[];
57
- export declare const ENCODER_CLASSES: StaticEncoderDecoder[];
58
- export declare const registerCustomTypeEncoder: (encoder: CustomTypeEncoder) => void;
59
- export {};
@@ -16,7 +16,7 @@ export type DateComponents = [number?, number?, number?];
16
16
  * 1. A number representing the number of milliseconds since the Unix epoch.
17
17
  * 2. A javascript Date object.
18
18
  * 3. An array of numbers satisfying the DateComponents type, where the first element is the
19
- * year, the second is the month, and the third is the day. To increaase resolution
19
+ * year, the second is the month, and the third is the day. To incraase resolution
20
20
  * when using this method, use the add method. It's important to note that this initializes
21
21
  * a timestamp at midnight UTC, regardless of the timezone specified.
22
22
  * 4. An ISO compliant date or date time string. The time zone component is ignored.
@@ -29,9 +29,13 @@ export type DateComponents = [number?, number?, number?];
29
29
  * @example ts = new TimeStamp([2021, 1, 1]).add(1 * TimeSpan.HOUR) // 1/1/2021 at 1am UTC
30
30
  * @example ts = new TimeStamp("2021-01-01T12:30:00Z") // 1/1/2021 at 12:30pm UTC
31
31
  */
32
- export declare class TimeStamp extends Number implements Stringer {
32
+ export declare class TimeStamp implements Stringer {
33
+ private readonly value;
34
+ readonly encodeValue: true;
33
35
  constructor(value?: CrudeTimeStamp, tzInfo?: TZInfo);
34
36
  private static parseDate;
37
+ encode(): string;
38
+ valueOf(): bigint;
35
39
  private static parseTimeString;
36
40
  private static parseDateTimeString;
37
41
  fString(format?: TimeStampStringFormat, tzInfo?: TZInfo): string;
@@ -153,13 +157,14 @@ export declare class TimeStamp extends Number implements Stringer {
153
157
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
154
158
  get isToday(): boolean;
155
159
  truncate(span: TimeSpan | TimeStamp): TimeStamp;
156
- get bigInt(): bigint;
157
160
  /**
158
161
  * @returns A new TimeStamp representing the current time in UTC. It's important to
159
162
  * note that this TimeStamp is only accurate to the millisecond level (that's the best
160
163
  * JavaScript can do).
161
164
  */
162
165
  static now(): TimeStamp;
166
+ static max(...timestamps: CrudeTimeStamp[]): TimeStamp;
167
+ static min(...timestamps: CrudeTimeStamp[]): TimeStamp;
163
168
  /** @returns a new TimeStamp n nanoseconds after the unix epoch */
164
169
  static nanoseconds(value: number): TimeStamp;
165
170
  static readonly NANOSECOND: TimeStamp;
@@ -194,18 +199,29 @@ export declare class TimeStamp extends Number implements Stringer {
194
199
  /** The unix epoch */
195
200
  static readonly ZERO: TimeStamp;
196
201
  /** A zod schema for validating timestamps */
197
- static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeStamp, Number>, z.ZodEffects<z.ZodNumber, TimeStamp, number>, z.ZodType<TimeStamp, z.ZodTypeDef, TimeStamp>]>;
202
+ static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
203
+ value: z.ZodBigInt;
204
+ }, "strip", z.ZodTypeAny, {
205
+ value: bigint;
206
+ }, {
207
+ value: bigint;
208
+ }>, TimeStamp, {
209
+ value: bigint;
210
+ }>, z.ZodEffects<z.ZodString, TimeStamp, string>, z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeStamp, Number>, z.ZodEffects<z.ZodNumber, TimeStamp, number>, z.ZodType<TimeStamp, z.ZodTypeDef, TimeStamp>]>;
198
211
  }
199
212
  /** TimeSpan represents a nanosecond precision duration. */
200
- export declare class TimeSpan extends Number implements Stringer {
213
+ export declare class TimeSpan implements Stringer {
214
+ private readonly value;
215
+ readonly encodeValue: true;
201
216
  constructor(value: CrudeTimeSpan);
217
+ encode(): string;
218
+ valueOf(): bigint;
202
219
  lessThan(other: CrudeTimeSpan): boolean;
203
220
  greaterThan(other: CrudeTimeSpan): boolean;
204
221
  lessThanOrEqual(other: CrudeTimeSpan): boolean;
205
222
  greaterThanOrEqual(other: CrudeTimeSpan): boolean;
206
223
  remainder(divisor: TimeSpan): TimeSpan;
207
224
  truncate(span: TimeSpan): TimeSpan;
208
- multiply(factor: number): TimeSpan;
209
225
  toString(): string;
210
226
  /** @returns the decimal number of days in the timespan */
211
227
  get days(): number;
@@ -313,7 +329,15 @@ export declare class TimeSpan extends Number implements Stringer {
313
329
  /** The zero value for a TimeSpan. */
314
330
  static readonly ZERO: TimeSpan;
315
331
  /** A zod schema for validating and transforming timespans */
316
- static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeSpan, Number>, z.ZodEffects<z.ZodNumber, TimeSpan, number>, z.ZodType<TimeSpan, z.ZodTypeDef, TimeSpan>]>;
332
+ static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
333
+ value: z.ZodBigInt;
334
+ }, "strip", z.ZodTypeAny, {
335
+ value: bigint;
336
+ }, {
337
+ value: bigint;
338
+ }>, TimeSpan, {
339
+ value: bigint;
340
+ }>, z.ZodEffects<z.ZodString, TimeSpan, string>, z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeSpan, Number>, z.ZodEffects<z.ZodNumber, TimeSpan, number>, z.ZodType<TimeSpan, z.ZodTypeDef, TimeSpan>]>;
317
341
  }
318
342
  /** Rate represents a data rate in Hz. */
319
343
  export declare class Rate extends Number implements Stringer {
@@ -490,17 +514,49 @@ export declare class TimeRange implements Stringer {
490
514
  static readonly ZERO: TimeRange;
491
515
  /** A zod schema for validating and transforming time ranges */
492
516
  static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
493
- start: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeStamp, Number>, z.ZodEffects<z.ZodNumber, TimeStamp, number>, z.ZodType<TimeStamp, z.ZodTypeDef, TimeStamp>]>;
494
- end: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeStamp, Number>, z.ZodEffects<z.ZodNumber, TimeStamp, number>, z.ZodType<TimeStamp, z.ZodTypeDef, TimeStamp>]>;
517
+ start: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
518
+ value: z.ZodBigInt;
519
+ }, "strip", z.ZodTypeAny, {
520
+ value: bigint;
521
+ }, {
522
+ value: bigint;
523
+ }>, TimeStamp, {
524
+ value: bigint;
525
+ }>, z.ZodEffects<z.ZodString, TimeStamp, string>, z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeStamp, Number>, z.ZodEffects<z.ZodNumber, TimeStamp, number>, z.ZodType<TimeStamp, z.ZodTypeDef, TimeStamp>]>;
526
+ end: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
527
+ value: z.ZodBigInt;
528
+ }, "strip", z.ZodTypeAny, {
529
+ value: bigint;
530
+ }, {
531
+ value: bigint;
532
+ }>, TimeStamp, {
533
+ value: bigint;
534
+ }>, z.ZodEffects<z.ZodString, TimeStamp, string>, z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeStamp, Number>, z.ZodEffects<z.ZodNumber, TimeStamp, number>, z.ZodType<TimeStamp, z.ZodTypeDef, TimeStamp>]>;
495
535
  }, "strip", z.ZodTypeAny, {
496
536
  start: TimeStamp;
497
537
  end: TimeStamp;
498
538
  }, {
499
- start: (number | Number | TimeStamp) & (number | Number | TimeStamp | undefined);
500
- end: (number | Number | TimeStamp) & (number | Number | TimeStamp | undefined);
539
+ start: (string | number | Number | TimeStamp | {
540
+ value: bigint;
541
+ }) & (string | number | Number | TimeStamp | {
542
+ value: bigint;
543
+ } | undefined);
544
+ end: (string | number | Number | TimeStamp | {
545
+ value: bigint;
546
+ }) & (string | number | Number | TimeStamp | {
547
+ value: bigint;
548
+ } | undefined);
501
549
  }>, TimeRange, {
502
- start: (number | Number | TimeStamp) & (number | Number | TimeStamp | undefined);
503
- end: (number | Number | TimeStamp) & (number | Number | TimeStamp | undefined);
550
+ start: (string | number | Number | TimeStamp | {
551
+ value: bigint;
552
+ }) & (string | number | Number | TimeStamp | {
553
+ value: bigint;
554
+ } | undefined);
555
+ end: (string | number | Number | TimeStamp | {
556
+ value: bigint;
557
+ }) & (string | number | Number | TimeStamp | {
558
+ value: bigint;
559
+ } | undefined);
504
560
  }>, z.ZodType<TimeRange, z.ZodTypeDef, TimeRange>]>;
505
561
  }
506
562
  /** DataType is a string that represents a data type. */
@@ -633,9 +689,9 @@ export declare class Size extends Number implements Stringer {
633
689
  static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodNumber, Size, number>, z.ZodType<Size, z.ZodTypeDef, Size>]>;
634
690
  get isZero(): boolean;
635
691
  }
636
- export type CrudeTimeStamp = TimeStamp | TimeSpan | number | Date | string | DateComponents | Number;
692
+ export type CrudeTimeStamp = bigint | BigInt | TimeStamp | TimeSpan | number | Date | string | DateComponents | Number;
637
693
  export type TimeStampT = number;
638
- export type CrudeTimeSpan = TimeSpan | TimeStamp | number | Number;
694
+ export type CrudeTimeSpan = bigint | BigInt | TimeSpan | TimeStamp | number | Number;
639
695
  export type TimeSpanT = number;
640
696
  export type CrudeRate = Rate | number | Number;
641
697
  export type RateT = number;