import { z } from 'zod'; import { math } from '../math'; import { primitive } from '../primitive'; import { bounds } from '../spatial'; import { TimestampFormat, TimeZone } from './types.gen'; /** Different string formats for time spans. */ export type TimeSpanStringFormat = "full" | "semantic"; declare const dateComponentsZ: z.ZodUnion, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>; /** * A triple of numbers representing a date. * * @param year - The year. * @param month - The month. * @param day - The day. */ export type DateComponents = z.infer; /** UTC timestamp. Synnax uses a nanosecond precision int64 timestamp. * * @param value - The timestamp value to parse. This can be any of the following: * * 1. A number representing the number of nanoseconds since the Unix epoch. * 2. A JavaScript Date object. * 3. An array of numbers satisfying the DateComponents type, where the first element is * the year, the second is the month, and the third is the day. To increase * resolution when using this method, use the add method. It's important to note that * this initializes a timestamp at midnight UTC, regardless of the TimeZone * specified. * 4. An ISO compliant date or date time string. The TimeZone component is ignored. * * @param timeZone - The TimeZone to use when parsing the TimeStamp. This can be either * "UTC" or "local". This parameter is ignored if the value is a Date object or a * DateComponents array. * * @example ts = new TimeStamp(1 * TimeSpan.HOUR) // 1 hour after the Unix epoch * @example ts = new TimeStamp([2021, 1, 1]) // 1/1/2021 midnight UTC * @example ts = new TimeStamp([2021, 1, 1]).add(1 * TimeSpan.HOUR) // 1/1/2021 1am UTC * @example ts = new TimeStamp("2021-01-01T12:30:00Z") // 1/1/2021 12:30pm UTC */ export declare class TimeStamp extends primitive.ValueExtension implements primitive.Stringer, primitive.Hashable { /** @returns the bigint nanosecond value as a string for stable hashing. */ hash(): string; constructor(value?: CrudeTimeStamp, timeZone?: TimeZone); private static parseDate; /** * @returns the primitive value of the TimeStamp. Overrides standard JS valueOf() * method. */ valueOf(): bigint; private static parseTimeString; private static parseDateTimeString; private toISOString; private timeString; private dateString; /** @returns The UTC offset for the time zone of the machine. */ static get utcOffset(): TimeSpan; /** * @returns a TimeSpan representing the amount time elapsed since * the other timestamp. * @param other - The other timestamp. */ static since(other: CrudeTimeStamp): TimeSpan; /** @returns A JavaScript Date object representing the TimeStamp. */ date(): Date; /** * Checks if the TimeStamp is equal to another TimeStamp. * * @param other - The other TimeStamp to compare to. * @returns True if the TimeStamps are equal, false otherwise. */ equals(other: CrudeTimeStamp): boolean; /** * Creates a TimeSpan representing the duration between the two timestamps. * * @param other - The other TimeStamp to compare to. * @returns A TimeSpan representing the duration between the two timestamps. * The span is guaranteed to be positive. */ span(other: CrudeTimeStamp): TimeSpan; /** * Creates a TimeRange spanning the given TimeStamp. * * @param other - The other TimeStamp to compare to. * @returns A TimeRange spanning the given TimeStamp that is guaranteed to be * valid, regardless of the TimeStamp order. */ range(other: CrudeTimeStamp): TimeRange; /** * Creates a TimeRange starting at the TimeStamp and spanning the given * TimeSpan. * * @param other - The TimeSpan to span. * @returns A TimeRange starting at the TimeStamp and spanning the given * TimeSpan. The TimeRange is guaranteed to be valid. */ spanRange(other: CrudeTimeSpan): TimeRange; /** * Checks if the TimeStamp represents the unix epoch. * * @returns True if the TimeStamp represents the unix epoch, false otherwise. */ get isZero(): boolean; /** * Checks if the TimeStamp is after the given TimeStamp. * * @param other - The other TimeStamp to compare to. * @returns True if the TimeStamp is after the given TimeStamp, false * otherwise. */ after(other: CrudeTimeStamp): boolean; /** * Checks if the TimeStamp is after or equal to the given TimeStamp. * * @param other - The other TimeStamp to compare to. * @returns True if the TimeStamp is after or equal to the given TimeStamp, * false otherwise. */ afterEq(other: CrudeTimeStamp): boolean; /** * Checks if the TimeStamp is before the given TimeStamp. * * @param other - The other TimeStamp to compare to. * @returns True if the TimeStamp is before the given TimeStamp, false * otherwise. */ before(other: CrudeTimeStamp): boolean; /** * Checks if TimeStamp is before or equal to the current timestamp. * * @param other - The other TimeStamp to compare to. * @returns True if TimeStamp is before or equal to the current timestamp, * false otherwise. */ beforeEq(other: CrudeTimeStamp): boolean; /** * Adds a TimeSpan to the TimeStamp. * * @param span - The TimeSpan to add. * @returns A new TimeStamp representing the sum of the TimeStamp and * TimeSpan. */ add(span: CrudeTimeSpan): TimeStamp; /** * Subtracts a TimeSpan from the TimeStamp. * * @param span - The TimeSpan to subtract. * @returns A new TimeStamp representing the difference of the TimeStamp and * TimeSpan. */ sub(span: CrudeTimeSpan): TimeStamp; /** * @returns the floating point number of hours since the unix epoch to the timestamp * value. */ get hours(): number; /** * @returns the floating point number of minutes since the unix epoch to the timestamp * value. */ get minutes(): number; /** * @returns the floating point number of days since the unix epoch to the timestamp * value. */ get days(): number; /** * @returns the floating point number of seconds since the unix epoch to the timestamp * value. */ get seconds(): number; /** @returns the floating point number of milliseconds since the unix epoch. */ get milliseconds(): number; /** @returns the floating point number of microseconds since the unix epoch. */ get microseconds(): number; /** * @returns the floating point number of nanoseconds since the unix epoch. * Note that since we're converting to float64, this reduces the resolution * to a quarter of a microsecond. */ get nanoseconds(): number; /** @returns the integer year that the timestamp corresponds to in UTC. */ get year(): number; /** @returns the integer year that the timestamp corresponds to in local time. */ get localYear(): number; /** * @returns a copy of the timestamp with the year changed in UTC. * @param year the value to set the year to. */ setYear(year: number): TimeStamp; /** * @returns a copy of the timestamp with the year changed in local time. * @param year the value to set the year to. */ setLocalYear(year: number): TimeStamp; /** @returns the integer month that the timestamp corresponds to within its year in * UTC. */ get month(): number; /** @returns the integer month that the timestamp corresponds to within its year in * local time. */ get localMonth(): number; /** * @returns a copy of the timestamp with the month changed in UTC. * @param month the value to set the month to. */ setMonth(month: number): TimeStamp; /** * @returns a copy of the timestamp with the month changed in local time. * @param month the value to set the month to. */ setLocalMonth(month: number): TimeStamp; /** @returns the integer day that the timestamp corresponds to within its month in * UTC. */ get day(): number; /** @returns the integer day that the timestamp corresponds to within its month in * local time. */ get localDay(): number; /** * @returns a copy of the timestamp with the day changed in UTC. * @param day the value the set the day to. */ setDay(day: number): TimeStamp; /** * @returns a copy of the timestamp with the day changed in local time. * @param day the value to set the day to. */ setLocalDay(day: number): TimeStamp; /** * @returns the integer hour that the timestamp corresponds to within its day. */ get hour(): number; /** * @returns the integer hour that the timestamp corresponds to within its day in local * time. */ get localHour(): number; /** * @returns a copy of the timestamp with the hour changed. * @param hour the value to set the hour to. */ setLocalHour(hour: number): TimeStamp; /** * @returns a copy of the timestamp with the hour changed. * @param hour the value to set the hour to. */ setHour(hour: number): TimeStamp; /** @returns the integer minute that the timestamp corresponds to within its hour in * UTC. */ get minute(): number; /** @returns the integer minute that the timestamp corresponds to within its hour in * local time. */ get localMinute(): number; /** * @returns a copy of the timestamp with the minute changed in UTC. * @param minute the value to set the minute to. */ setMinute(minute: number): TimeStamp; /** * @returns a copy of the timestamp with the minute changed in local time. * @param minute the value to set the minute to. */ setLocalMinute(minute: number): TimeStamp; /** * @returns the integer second that the timestamp corresponds to within its * minute in UTC. */ get second(): number; /** * @returns the integer second that the timestamp corresponds to within its minute in * local time. */ get localSecond(): number; /** * @returns a copy of the timestamp with the second changed in UTC. * @param second the value to set the second to. */ setSecond(second: number): TimeStamp; /** * @returns a copy of the timestamp with the second changed in local time. * @param second the value to set the second to. */ setLocalSecond(second: number): TimeStamp; /** * @returns the integer millisecond that the timestamp corresponds to within its * second in UTC. */ get millisecond(): number; /** * @returns the integer millisecond that the timestamp corresponds to within its * second in local time. */ get localMillisecond(): number; /** * @returns a copy of the timestamp with the milliseconds changed in UTC. * @param millisecond the value to set the millisecond to. */ setMillisecond(millisecond: number): TimeStamp; /** * @returns a copy of the timestamp with the milliseconds changed in local time. * @param millisecond the value to set the millisecond to. */ setLocalMillisecond(millisecond: number): TimeStamp; /** * Returns a string representation of the TimeStamp. * * @param format - Optional format for the string representation. Defaults to "ISO". * @param timeZone - Optional TimeZone. Defaults to "UTC". * @returns A string representation of the TimeStamp. */ toString(format?: TimestampFormat, timeZone?: TimeZone): string; /** * @returns A new TimeStamp that is the remainder of the TimeStamp divided by the * given span. This is useful in cases where you want only part of a TimeStamp's value * i.e., the hours, minutes, seconds, milliseconds, microseconds, and nanoseconds but * not the days, years, etc. * * @param divisor - The TimeSpan to divide by. Must be an even TimeSpan or TimeStamp. Even * means it must be a day, hour, minute, second, millisecond, or microsecond, etc. * * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day */ remainder(divisor: TimeSpan | TimeStamp): TimeStamp; /** @returns true if the day portion TimeStamp is today, false otherwise. */ get isToday(): boolean; /** * Truncates the TimeStamp to the nearest multiple of the given span. * * @param span - The TimeSpan to truncate to. * @returns A new TimeStamp that is truncated to the nearest multiple of the given span. */ truncate(span: TimeSpan | TimeStamp): TimeStamp; /** * Determines the appropriate string format based on the span magnitude. * * @param span - The span that provides context for format selection * @returns The appropriate TimestampFormat * * Rules: * - For spans >= 30 days: "date" (e.g., "Nov 5") * - For spans >= 1 day: "dateTime" (e.g., "Nov 5 14:23:45") * - For spans >= 1 hour: "time" (e.g., "14:23:45") * - For spans < 1 hour: "preciseTime" (e.g., "14:23:45.123") */ formatBySpan(span: TimeSpan): TimestampFormat; /** * @returns A new TimeStamp representing the current time in UTC. It's important to * note that this TimeStamp is only accurate to the millisecond level (that's the best * JavaScript can do). */ static now(): TimeStamp; /** * Finds the maximum timestamp among the provided timestamps. * * @param timestamps - The timestamps to compare. * @returns The maximum (latest) timestamp from the input. */ static max(...timestamps: CrudeTimeStamp[]): TimeStamp; /** * Finds the minimum timestamp among the provided timestamps. * * @param timestamps - The timestamps to compare. * @returns The minimum (earliest) timestamp from the input. */ static min(...timestamps: CrudeTimeStamp[]): TimeStamp; /** * Creates a TimeStamp representing the given number of nanoseconds. * * @param value - The number of nanoseconds. * @returns A TimeStamp representing the given number of nanoseconds. */ static nanoseconds(value: number, timeZone?: TimeZone): TimeStamp; /** One nanosecond after the unix epoch */ static readonly NANOSECOND: TimeStamp; /** @returns a new TimeStamp n microseconds after the unix epoch */ static microseconds(value: number, timeZone?: TimeZone): TimeStamp; /** One microsecond after the unix epoch */ static readonly MICROSECOND: TimeStamp; /** @returns a new TimeStamp n milliseconds after the unix epoch */ static milliseconds(value: number, timeZone?: TimeZone): TimeStamp; /** One millisecond after the unix epoch */ static readonly MILLISECOND: TimeStamp; /** @returns a new TimeStamp n seconds after the unix epoch */ static seconds(value: number, timeZone?: TimeZone): TimeStamp; /** One second after the unix epoch */ static readonly SECOND: TimeStamp; /** @returns a new TimeStamp n minutes after the unix epoch */ static minutes(value: number, timeZone?: TimeZone): TimeStamp; /** One minute after the unix epoch */ static readonly MINUTE: TimeStamp; /** @returns a new TimeStamp n hours after the unix epoch */ static hours(value: number, timeZone?: TimeZone): TimeStamp; /** One hour after the unix epoch */ static readonly HOUR: TimeStamp; /** @returns a new TimeStamp n days after the unix epoch */ static days(value: number, timeZone?: TimeZone): TimeStamp; /** One day after the unix epoch */ static readonly DAY: TimeStamp; /** The maximum possible value for a timestamp */ static readonly MAX: TimeStamp; /** The minimum possible value for a timestamp */ static readonly MIN: TimeStamp; /** The unix epoch */ static readonly ZERO: TimeStamp; /** A zod schema for validating timestamps */ static readonly z: z.ZodUnion, z.ZodPipe, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>, z.ZodTransform>]>; /** * Sorts two timestamps. * * @param a - The first timestamp. * @param b - The second timestamp. * @returns A number indicating the order of the two timestamps (positive if a is * greater than b, negative if a is less than b, and 0 if they are equal). */ static sort(a: TimeStamp, b: TimeStamp): number; } /** TimeSpan represents a nanosecond precision duration. */ export declare class TimeSpan extends primitive.ValueExtension implements primitive.Stringer, primitive.Hashable { constructor(value: CrudeTimeSpan); /** * Creates a TimeSpan representing the given number of seconds. * * @param span - The number of seconds. * @returns A TimeSpan representing the given number of seconds. */ static fromSeconds(span: CrudeTimeSpan): TimeSpan; /** * Creates a TimeSpan representing the given number of milliseconds. * * @param span - The number of milliseconds. * @returns A TimeSpan representing the given number of milliseconds. */ static fromMilliseconds(span: CrudeTimeSpan): TimeSpan; /** * @returns the primitive value of the TimeSpan. Overrides standard JS valueOf() * method. */ valueOf(): bigint; /** @returns the bigint nanosecond value as a string for stable hashing. */ hash(): string; /** * Checks if the TimeSpan is less than another TimeSpan. * * @param other - The TimeSpan to compare against. * @returns True if the TimeSpan is less than the other TimeSpan, false otherwise. */ lessThan(other: CrudeTimeSpan): boolean; /** * Checks if the TimeSpan is greater than another TimeSpan. * * @param other - The TimeSpan to compare against. * @returns True if the TimeSpan is greater than the other TimeSpan, false otherwise. */ greaterThan(other: CrudeTimeSpan): boolean; /** * Checks if the TimeSpan is less than or equal to another TimeSpan. * * @param other - The TimeSpan to compare against. * @returns True if the TimeSpan is less than or equal to the other TimeSpan, false otherwise. */ lessThanOrEqual(other: CrudeTimeSpan): boolean; /** * Checks if the TimeSpan is greater than or equal to another TimeSpan. * * @param other - The TimeSpan to compare against. * @returns True if the TimeSpan is greater than or equal to the other TimeSpan, false otherwise. */ greaterThanOrEqual(other: CrudeTimeSpan): boolean; /** * Calculates the remainder of the TimeSpan when divided by another TimeSpan. * * @param divisor - The TimeSpan to divide by. * @returns A new TimeSpan representing the remainder. */ remainder(divisor: TimeSpan): TimeSpan; /** * Truncates the TimeSpan to the nearest multiple of the given span. * * @param span - The TimeSpan to truncate to. * @returns A new TimeSpan that is truncated to the nearest multiple of the given span. */ truncate(span: TimeSpan): TimeSpan; /** * Returns a string representation of the TimeSpan. * * @param format - Optional format for the string representation. Defaults to "full". * - "full": Shows all non-zero units with full precision (e.g., "2d 3h 45m 12s 500ms") * - "semantic": Shows 1-2 most significant units (e.g., "2d 3h") * @returns A string representation of the TimeSpan. */ toString(format?: TimeSpanStringFormat): string; private toSemanticString; /** * Multiplies the TimeSpan by a scalar value. * * @param value - The scalar value to multiply by. * @returns A new TimeSpan that is this TimeSpan multiplied by the provided value. */ mult(value: number): TimeSpan; /** * Divides the TimeSpan by a scalar value. * * @param value - The scalar value to divide by. * @returns A new TimeSpan that is this TimeSpan divided by the provided value. */ div(value: number): TimeSpan; /** @returns the decimal number of days in the TimeSpan. */ get days(): number; /** @returns the decimal number of hours in the TimeSpan. */ get hours(): number; /** @returns the decimal number of minutes in the TimeSpan. */ get minutes(): number; /** @returns The number of seconds in the TimeSpan. */ get seconds(): number; /** @returns The number of milliseconds in the TimeSpan. */ get milliseconds(): number; /** @returns The number of microseconds in the TimeSpan. */ get microseconds(): number; /** @returns The number of nanoseconds in the TimeSpan. */ get nanoseconds(): number; /** * Checks if the TimeSpan represents a zero duration. * * @returns True if the TimeSpan represents a zero duration, false otherwise. */ get isZero(): boolean; /** * Checks if the TimeSpan is equal to another TimeSpan. * * @returns True if the TimeSpans are equal, false otherwise. */ equals(other: CrudeTimeSpan): boolean; /** * Adds a TimeSpan to the TimeSpan. * * @returns A new TimeSpan representing the sum of the two TimeSpans. */ add(other: CrudeTimeSpan): TimeSpan; /** * Creates a TimeSpan representing the duration between the two timestamps. * * @param other */ sub(other: CrudeTimeSpan): TimeSpan; abs(): TimeSpan; /** * Creates a TimeSpan representing the given number of nanoseconds. * * @param value - The number of nanoseconds. * @returns A TimeSpan representing the given number of nanoseconds. */ static nanoseconds(value?: math.Numeric): TimeSpan; /** A nanosecond. */ static readonly NANOSECOND: TimeSpan; /** * Creates a TimeSpan representing the given number of microseconds. * * @param value - The number of microseconds. * @returns A TimeSpan representing the given number of microseconds. */ static microseconds(value?: math.Numeric): TimeSpan; /** A microsecond. */ static readonly MICROSECOND: TimeSpan; /** * Creates a TimeSpan representing the given number of milliseconds. * * @param value - The number of milliseconds. * @returns A TimeSpan representing the given number of milliseconds. */ static milliseconds(value?: math.Numeric): TimeSpan; /** A millisecond. */ static readonly MILLISECOND: TimeSpan; /** * Creates a TimeSpan representing the given number of seconds. * * @param value - The number of seconds. * @returns A TimeSpan representing the given number of seconds. */ static seconds(value?: math.Numeric): TimeSpan; /** A second. */ static readonly SECOND: TimeSpan; /** * Creates a TimeSpan representing the given number of minutes. * * @param value - The number of minutes. * @returns A TimeSpan representing the given number of minutes. */ static minutes(value?: math.Numeric): TimeSpan; /** A minute. */ static readonly MINUTE: TimeSpan; /** * Creates a TimeSpan representing the given number of hours. * * @param value - The number of hours. * @returns A TimeSpan representing the given number of hours. */ static hours(value: math.Numeric): TimeSpan; /** Represents an hour. */ static readonly HOUR: TimeSpan; /** * Creates a TimeSpan representing the given number of days. * * @param value - The number of days. * @returns A TimeSpan representing the given number of days. */ static days(value: math.Numeric): TimeSpan; /** Represents a day. */ static readonly DAY: TimeSpan; /** The maximum possible value for a TimeSpan. */ static readonly MAX: TimeSpan; /** The minimum possible value for a TimeSpan. */ static readonly MIN: TimeSpan; /** The zero value for a TimeSpan. */ static readonly ZERO: TimeSpan; /** A zod schema for validating and transforming time spans */ static readonly z: z.ZodUnion, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodCustom, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTransform>]>; } /** Rate represents a data rate in Hz. */ export declare class Rate extends primitive.ValueExtension implements primitive.Stringer, primitive.Hashable { constructor(value: CrudeRate); /** @returns the Hz value as a string for stable hashing. */ hash(): string; /** @returns a pretty string representation of the rate in the format "X Hz". */ toString(): string; /** @returns The number of seconds in the Rate. */ equals(other: CrudeRate): boolean; /** * Calculates the period of the Rate as a TimeSpan. * * @returns A TimeSpan representing the period of the Rate. */ get period(): TimeSpan; /** * Calculates the number of samples in the given TimeSpan at this rate. * * @param duration - The duration to calculate the sample count from. * @returns The number of samples in the given TimeSpan at this rate. */ sampleCount(duration: CrudeTimeSpan): number; /** * Calculates the number of bytes in the given TimeSpan at this rate. * * @param span - The duration to calculate the byte count from. * @param density - The density of the data in bytes per sample. * @returns The number of bytes in the given TimeSpan at this rate. */ byteCount(span: CrudeTimeSpan, density: CrudeDensity): number; /** * Calculates a TimeSpan given the number of samples at this rate. * * @param sampleCount - The number of samples in the span. * @returns A TimeSpan that corresponds to the given number of samples. */ span(sampleCount: number): TimeSpan; /** * Calculates a TimeSpan given the number of bytes at this rate. * * @param size - The number of bytes in the span. * @param density - The density of the data in bytes per sample. * @returns A TimeSpan that corresponds to the given number of bytes. */ byteSpan(size: Size, density: CrudeDensity): TimeSpan; /** * Adds another Rate to this Rate. * * @param other - The Rate to add. * @returns A new Rate representing the sum of the two rates. */ add(other: CrudeRate): Rate; /** * Subtracts another Rate from this Rate. * * @param other - The Rate to subtract. * @returns A new Rate representing the difference of the two rates. */ sub(other: CrudeRate): Rate; /** * Multiplies this Rate by a scalar value. * * @param value - The scalar value to multiply by. * @returns A new Rate representing this Rate multiplied by the value. */ mult(value: number): Rate; /** * Divides this Rate by a scalar value. * * @param value - The scalar value to divide by. * @returns A new Rate representing this Rate divided by the value. */ div(value: number): Rate; /** * Creates a Rate representing the given number of Hz. * * @param value - The number of Hz. * @returns A Rate representing the given number of Hz. */ static hz(value: number): Rate; /** * Creates a Rate representing the given number of kHz. * * @param value - The number of kHz. * @returns A Rate representing the given number of kHz. */ static khz(value: number): Rate; /** A zod schema for validating and transforming rates */ static readonly z: z.ZodUnion>, z.ZodCustom]>; } /** Density represents the number of bytes in a value. */ export declare class Density extends primitive.ValueExtension implements primitive.Stringer { /** * Creates a Density representing the given number of bytes per value. * * @class * @param value - The number of bytes per value. * @returns A Density representing the given number of bytes per value. */ constructor(value: CrudeDensity); /** * Calculates the number of values in the given Size. * * @param size - The Size to calculate the value count from. * @returns The number of values in the given Size. */ length(size: Size): number; /** * Calculates a Size representing the given number of values. * * @param sampleCount - The number of values in the Size. * @returns A Size representing the given number of values. */ size(sampleCount: number): Size; /** * Adds another Density to this Density. * * @param other - The Density to add. * @returns A new Density representing the sum of the two densities. */ add(other: CrudeDensity): Density; /** * Subtracts another Density from this Density. * * @param other - The Density to subtract. * @returns A new Density representing the difference of the two densities. */ sub(other: CrudeDensity): Density; /** * Multiplies this Density by a scalar value. * * @param value - The scalar value to multiply by. * @returns A new Density representing this Density multiplied by the value. */ mult(value: number): Density; /** * Divides this Density by a scalar value. * * @param value - The scalar value to divide by. * @returns A new Density representing this Density divided by the value. */ div(value: number): Density; /** Unknown/Invalid Density. */ static readonly UNKNOWN: Density; /** 128 bits per value. */ static readonly BIT128: Density; /** 64 bits per value. */ static readonly BIT64: Density; /** 32 bits per value. */ static readonly BIT32: Density; /** 16 bits per value. */ static readonly BIT16: Density; /** 8 bits per value. */ static readonly BIT8: Density; /** A zod schema for validating and transforming densities */ static readonly z: z.ZodUnion>, z.ZodCustom]>; } /** * TimeRange is a range of time marked by a start and end timestamp. A TimeRange * is start inclusive and end exclusive. * * @property start - A TimeStamp representing the start of the range. * @property end - A Timestamp representing the end of the range. */ export declare class TimeRange implements primitive.Stringer, primitive.Hashable { /** @returns a stable hash composed of the start and end timestamps. */ hash(): string; /** * The starting TimeStamp of the TimeRange. * * Note that this value is not guaranteed to be before or equal to the ending value. * To ensure that this is the case, call TimeRange.make_valid(). * * In most cases, operations should treat start as inclusive. */ start: TimeStamp; /** * The starting TimeStamp of the TimeRange. * * Note that this value is not guaranteed to be before or equal to the ending value. * To ensure that this is the case, call TimeRange.make_valid(). * * In most cases, operations should treat end as exclusive. */ end: TimeStamp; constructor(tr: CrudeTimeRange); constructor(start: CrudeTimeStamp, end: CrudeTimeStamp); /** @returns The TimeSpan occupied by the TimeRange. */ get span(): TimeSpan; /** * Checks if the timestamp is valid i.e. the start is before the end. * * @returns True if the TimeRange is valid. */ get isValid(): boolean; /** * Makes sure the TimeRange is valid i.e. the start is before the end. * * @returns A TimeRange that is valid. */ makeValid(): TimeRange; /** * Checks if the TimeRange is zero (both start and end are TimeStamp.ZERO). * * @returns True if both start and end are TimeStamp.ZERO, false otherwise. */ get isZero(): boolean; /** * @returns the TimeRange as a numeric object with start and end properties. */ get numeric(): NumericTimeRange; /** * Creates a new TimeRange with the start and end swapped. * * @returns A TimeRange with the start and end swapped. */ swap(): TimeRange; get numericBounds(): bounds.Bounds; /** * Checks if the TimeRange is equal to the given TimeRange. * * @param other - The TimeRange to compare to. * @returns True if the TimeRange is equal to the given TimeRange. */ equals(other: TimeRange, delta?: TimeSpan): boolean; /** * Returns a string representation of the TimeRange. * * @returns A string representation of the TimeRange. */ toString(): string; /** * Returns a pretty string representation of the TimeRange. * * @returns A pretty string representation of the TimeRange. */ toPrettyString(): string; /** * Checks if the two time ranges overlap. If the two time ranges are equal, returns * true. If the start of one range is equal to the end of the other, it returns false. * Just follow the rule [start, end), i.e., start is inclusive, and the end is exclusive. * * @param other - The other TimeRange to compare to. * @param delta - A TimeSpan representing the minimum amount of overlap for * overlap to return true. This allows for a slight amount of leeway when * checking for overlap. * @returns True if the two TimeRanges overlap, false otherwise. */ overlapsWith(other: TimeRange, delta?: TimeSpan): boolean; /** * Checks if the TimeRange contains the given TimeRange or TimeStamp. * * @param other - The TimeRange or TimeStamp to check if it is contained in the TimeRange. * @returns True if the TimeRange contains the given TimeRange or TimeStamp. */ contains(other: TimeRange): boolean; /** * Checks if the TimeRange contains the given TimeStamp. * * @param ts - The TimeStamp to check if it is contained in the TimeRange. * @returns True if the TimeRange contains the given TimeStamp. */ contains(ts: CrudeTimeStamp): boolean; /** * Returns a new TimeRange that is bound by the given TimeRange. * * @param other - The TimeRange to bound by. * @returns A new TimeRange that is bound by the given TimeRange. * @example * const range = new TimeRange(new TimeStamp(1000), new TimeStamp(2000)); * const other = new TimeRange(new TimeStamp(1500), new TimeStamp(2500)); * const bounded = range.boundBy(other); * console.log(bounded); // TimeRange(1500, 2000) */ boundBy(other: TimeRange): TimeRange; static max(...others: TimeRange[]): TimeRange; /** The maximum possible time range. */ static readonly MAX: TimeRange; /** A time range whose start and end are both zero. */ static readonly ZERO: TimeRange; /** A zod schema for validating and transforming time ranges */ static readonly z: z.ZodUnion, z.ZodPipe, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>, z.ZodTransform>]>; end: z.ZodUnion, z.ZodPipe, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>, z.ZodTransform>]>; }, z.core.$strip>, z.ZodTransform>, z.ZodCustom]>; /** * A zod schema that validates time ranges with bounds checking. * Ensures the range is valid (start <= end) and within int64 bounds. */ static readonly boundedZ: z.ZodUnion, z.ZodPipe, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>, z.ZodTransform>]>; end: z.ZodUnion, z.ZodPipe, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>, z.ZodTransform>]>; }, z.core.$strip>, z.ZodTransform>, z.ZodCustom]>; /** * Sorts two time ranges. The range with the earlier start time is considered less than * the range with the later start time. If the start times are equal, the range with the * earlier end time is considered less than the range with the later end time. * * @param a - The first time range. * @param b - The second time range. * @returns A number indicating the order of the two time ranges. This number is * positive if a is earlier than b, negative if a is later than b, and 0 if they are * equal. */ static sort(a: TimeRange, b: TimeRange): number; /** * Merges the given time ranges into a single time range. * * @param ranges - The list of `CrudeTimeRange`s to merge. * @returns A new `TimeRange` that is the union of the given time ranges - the start * is the minimum of the start times and the end is the maximum of the end times. */ static merge(...ranges: CrudeTimeRange[]): TimeRange; } /** DataType is a string that represents a data type. */ export declare class DataType extends primitive.ValueExtension implements primitive.Stringer, primitive.Hashable { /** @returns the data type identifier as a string for stable hashing. */ hash(): string; constructor(value: CrudeDataType); /** * @returns the TypedArray constructor for the DataType. */ get Array(): TypedArrayConstructor; /** * @returns true if the DataType is equal to the given DataType. */ equals(other: CrudeDataType): boolean; /** * @returns true if the DataType is equal to any of the given DataTypes. */ matches(...others: CrudeDataType[]): boolean; /** @returns a string representation of the DataType. If short is true, a 1-4 * character representation (i64, str, etc.) is returned instead. */ toString(short?: boolean): string; /** * @returns true if the DataType has a variable density. * @example DataType.STRING.isVariable // true * @example DataType.INT32.isVariable // false */ get isVariable(): boolean; /** * @returns true if the DataType is numeric. * @example DataType.INT32.isNumeric // true * @example DataType.STRING.isNumeric // false */ get isNumeric(): boolean; /** * @returns true if the DataType is an integer. * @example DataType.INT32.isInteger // true * @example DataType.FLOAT32.isInteger // false */ get isInteger(): boolean; /** * @returns true if the DataType is a floating point number. * @example DataType.FLOAT32.isFloat // true * @example DataType.INT32.isFloat // false */ get isFloat(): boolean; /** * @returns the density of the DataType. * @example DataType.INT16.density // Density.BIT32 * @example DataType.FLOAT32.density // Density.BIT32 */ get density(): Density; /** * @returns true if the DataType is an unsigned integer. * @example DataType.UINT32.isUnsigned // true * @example DataType.INT32.isUnsigned // false */ get isUnsignedInteger(): boolean; /** * @returns true if the DataType is a signed integer. * @example DataType.INT32.isSigned // true * @example DataType.UINT32.isSigned // false */ get isSignedInteger(): boolean; /** @returns true if the data type can be cast to the other data type without loss of precision. */ canSafelyCastTo(other: DataType): boolean; /** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */ canCastTo(other: DataType): boolean; /** * Checks whether the given TypedArray is of the same type as the DataType. * * @param array - The TypedArray to check. * @returns True if the TypedArray is of the same type as the DataType. */ checkArray(array: TypedArray): boolean; /** @returns true if the data type uses bigints to store values. */ get usesBigInt(): boolean; /** Represents an Unknown/Invalid DataType. */ static readonly UNKNOWN: DataType; /** Represents a 64-bit floating point value. */ static readonly FLOAT64: DataType; /** Represents a 32-bit floating point value. */ static readonly FLOAT32: DataType; /** Represents a 64-bit signed integer value. */ static readonly INT64: DataType; /** Represents a 32-bit signed integer value. */ static readonly INT32: DataType; /** Represents a 16-bit signed integer value. */ static readonly INT16: DataType; /** Represents a 8-bit signed integer value. */ static readonly INT8: DataType; /** Represents a 64-bit unsigned integer value. */ static readonly UINT64: DataType; /** Represents a 32-bit unsigned integer value. */ static readonly UINT32: DataType; /** Represents a 16-bit unsigned integer value. */ static readonly UINT16: DataType; /** Represents a 8-bit unsigned integer value. */ static readonly UINT8: DataType; /** Represents a 64-bit unix epoch. */ static readonly TIMESTAMP: DataType; /** Represents a UUID data type. */ static readonly UUID: DataType; /** Represents a string data type. Strings have an unknown density and are encoded * as uint32-length-prefixed samples. */ static readonly STRING: DataType; /** Represents a JSON data type. JSON has an unknown density and is encoded as * uint32-length-prefixed samples. */ static readonly JSON: DataType; /** Represents a bytes data type for arbitrary byte arrays. Bytes have an unknown * density and are encoded as uint32-length-prefixed samples. */ static readonly BYTES: DataType; private static readonly ARRAY_CONSTRUCTORS; private static readonly ARRAY_CONSTRUCTOR_DATA_TYPES; private static readonly DENSITIES; /** All the data types. */ static readonly ALL: DataType[]; private static readonly SHORT_STRINGS; static readonly BIG_INT_TYPES: DataType[]; /** A zod schema for a DataType. */ static readonly z: z.ZodUnion>, z.ZodCustom]>; } /** * The Size of an element in bytes. */ export declare class Size extends primitive.ValueExtension implements primitive.Stringer { constructor(value: CrudeSize); /** @returns true if the Size is larger than the other size. */ largerThan(other: CrudeSize): boolean; /** @returns true if the Size is smaller than the other size. */ smallerThan(other: CrudeSize): boolean; /** @returns a new Size representing the sum of the two Sizes. */ add(other: CrudeSize): Size; /** @returns a new Size representing the difference of the two Sizes. */ sub(other: CrudeSize): Size; /** * Multiplies this Size by a scalar value. * * @param value - The scalar value to multiply by. * @returns A new Size representing this Size multiplied by the value. */ mult(value: number): Size; /** * Divides this Size by a scalar value. * * @param value - The scalar value to divide by. * @returns A new Size representing this Size divided by the value. */ div(value: number): Size; /** @returns a new Size representing the truncated value of the Size. */ truncate(span: CrudeSize): Size; /** @returns a new Size representing the remainder of the Size. */ remainder(span: CrudeSize): Size; /** @returns the number of gigabytes in the Size. */ get gigabytes(): number; /** @returns the number of megabytes in the Size. */ get megabytes(): number; /** @returns the number of kilobytes in the Size. */ get kilobytes(): number; /** @returns the number of terabytes in the Size. */ get terabytes(): number; /** @returns a nicely formatted string representation of the Size. */ toString(): string; /** * Creates a Size from the given number of bytes. * * @param value - The number of bytes. * @returns A Size representing the given number of bytes. */ static bytes(value?: CrudeSize): Size; /** A single byte */ static readonly BYTE: Size; /** * Creates a Size from the given number if kilobytes. * * @param value - The number of kilobytes. * @returns A Size representing the given number of kilobytes. */ static kilobytes(value?: CrudeSize): Size; /** A kilobyte */ static readonly KILOBYTE: Size; /** * Creates a Size from the given number of megabytes. * * @param value - The number of megabytes. * @returns A Size representing the given number of megabytes. */ static megabytes(value?: CrudeSize): Size; /** A megabyte */ static readonly MEGABYTE: Size; /** * Creates a Size from the given number of gigabytes. * * @param value - The number of gigabytes. * @returns A Size representing the given number of gigabytes. */ static gigabytes(value?: CrudeSize): Size; /** A gigabyte */ static readonly GIGABYTE: Size; /** * Creates a Size from the given number of terabytes. * * @param value - The number of terabytes. * @returns A Size representing the given number of terabytes. */ static terabytes(value: CrudeSize): Size; /** A terabyte. */ static readonly TERABYTE: Size; /** The zero value for Size */ static readonly ZERO: Size; /** A zod schema for a Size. */ static readonly z: z.ZodUnion>, z.ZodCustom]>; /** @returns true if the Size is zero. */ get isZero(): boolean; } export type CrudeTimeStamp = bigint | TimeStamp | TimeSpan | number | Date | string | DateComponents | primitive.CrudeValueExtension; export type TimeStampT = number; export type CrudeTimeSpan = bigint | TimeSpan | TimeStamp | number | Rate | primitive.CrudeValueExtension; export type TimeSpanT = number; export type CrudeRate = Rate | number | primitive.CrudeValueExtension; export type RateT = number; export type CrudeDensity = Density | number | primitive.CrudeValueExtension; export type DensityT = number; export type CrudeDataType = DataType | string | TypedArray | primitive.CrudeValueExtension; export type DataTypeT = string; export type CrudeSize = Size | number | primitive.CrudeValueExtension; export type SizeT = number; export interface CrudeTimeRange { start: CrudeTimeStamp; end: CrudeTimeStamp; } export declare const numericTimeRangeZ: z.ZodObject<{ start: z.ZodNumber; end: z.ZodNumber; }, z.core.$strip>; /** * A time range backed by numbers instead of TimeStamps/BigInts. * Involves a loss of precision, but can be useful for serialization. */ export interface NumericTimeRange extends z.infer { } export declare const typedArrayZ: z.ZodUnion, Uint8Array>, z.ZodCustom, Uint16Array>, z.ZodCustom, Uint32Array>, z.ZodCustom, BigUint64Array>, z.ZodCustom, Float32Array>, z.ZodCustom, Float64Array>, z.ZodCustom, Int8Array>, z.ZodCustom, Int16Array>, z.ZodCustom, Int32Array>, z.ZodCustom, BigInt64Array>]>; export type TypedArray = z.infer; type TypedArrayConstructor = Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | BigUint64ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | Int8ArrayConstructor | Int16ArrayConstructor | Int32ArrayConstructor | BigInt64ArrayConstructor; export type TelemValue = number | bigint | string | boolean | Date | TimeStamp | TimeSpan; export declare const isTelemValue: (value: unknown) => value is TelemValue; export declare const convertDataType: (source: DataType, target: DataType, value: math.Numeric, offset?: math.Numeric) => math.Numeric; export declare const timeRangeZ: z.ZodUnion, z.ZodPipe, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>, z.ZodTransform>]>; end: z.ZodUnion, z.ZodPipe, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>, z.ZodTransform>]>; }, z.core.$strip>, z.ZodTransform>, z.ZodCustom]>; export declare const timeStampZ: z.ZodUnion, z.ZodPipe, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>, z.ZodTransform>]>; export declare const timeSpanZ: z.ZodUnion, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodCustom, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTransform>]>; export declare const rateZ: z.ZodUnion>, z.ZodCustom]>; export declare const sizeZ: z.ZodUnion>, z.ZodCustom]>; export declare const dataTypeZ: z.ZodUnion>, z.ZodCustom]>; export declare const timeRangeBoundedZ: z.ZodUnion, z.ZodPipe, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>, z.ZodTransform>]>; end: z.ZodUnion, z.ZodPipe, z.ZodTransform>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe>, z.ZodPipe, z.ZodTransform>, z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt], null>, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>]>, z.ZodTransform>]>; }, z.core.$strip>, z.ZodTransform>, z.ZodCustom]>; export {}; //# sourceMappingURL=telem.d.ts.map