@reifydb/core 0.0.1-alpha.7 → 0.0.1-alpha.8
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.
- package/dist/index.d.ts +62 -43
- package/dist/index.js +109 -60
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -364,6 +364,23 @@ declare class DateTimeValue implements Value {
|
|
|
364
364
|
encode(): TypeValuePair;
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
+
/**
|
|
368
|
+
* MIT License
|
|
369
|
+
* Copyright (c) 2025 ReifyDB
|
|
370
|
+
* See license.md file for full license text
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
declare class DecimalValue implements Value {
|
|
374
|
+
readonly type: Type;
|
|
375
|
+
readonly value?: string;
|
|
376
|
+
constructor(value?: string);
|
|
377
|
+
static parse(str: string): DecimalValue;
|
|
378
|
+
valueOf(): string | undefined;
|
|
379
|
+
toString(): string;
|
|
380
|
+
equals(other: Value): boolean;
|
|
381
|
+
encode(): TypeValuePair;
|
|
382
|
+
}
|
|
383
|
+
|
|
367
384
|
/**
|
|
368
385
|
* MIT License
|
|
369
386
|
* Copyright (c) 2025 ReifyDB
|
|
@@ -524,10 +541,10 @@ declare class Int16Value implements Value {
|
|
|
524
541
|
*/
|
|
525
542
|
|
|
526
543
|
/**
|
|
527
|
-
*
|
|
544
|
+
* A duration value representing a time span or elapsed time.
|
|
528
545
|
* Internally stored as months, days, and nanoseconds.
|
|
529
546
|
*/
|
|
530
|
-
declare class
|
|
547
|
+
declare class DurationValue implements Value {
|
|
531
548
|
readonly type: Type;
|
|
532
549
|
private readonly months?;
|
|
533
550
|
private readonly days?;
|
|
@@ -538,61 +555,61 @@ declare class IntervalValue implements Value {
|
|
|
538
555
|
nanos: bigint;
|
|
539
556
|
} | string);
|
|
540
557
|
/**
|
|
541
|
-
* Create a new
|
|
558
|
+
* Create a new duration from months, days, and nanoseconds
|
|
542
559
|
*/
|
|
543
|
-
static new(months: number, days: number, nanos: bigint):
|
|
560
|
+
static new(months: number, days: number, nanos: bigint): DurationValue;
|
|
544
561
|
/**
|
|
545
|
-
* Create
|
|
562
|
+
* Create a duration from seconds
|
|
546
563
|
*/
|
|
547
|
-
static fromSeconds(seconds: number):
|
|
564
|
+
static fromSeconds(seconds: number): DurationValue;
|
|
548
565
|
/**
|
|
549
|
-
* Create
|
|
566
|
+
* Create a duration from milliseconds
|
|
550
567
|
*/
|
|
551
|
-
static fromMilliseconds(milliseconds: number):
|
|
568
|
+
static fromMilliseconds(milliseconds: number): DurationValue;
|
|
552
569
|
/**
|
|
553
|
-
* Create
|
|
570
|
+
* Create a duration from microseconds
|
|
554
571
|
*/
|
|
555
|
-
static fromMicroseconds(microseconds: number):
|
|
572
|
+
static fromMicroseconds(microseconds: number): DurationValue;
|
|
556
573
|
/**
|
|
557
|
-
* Create
|
|
574
|
+
* Create a duration from nanoseconds
|
|
558
575
|
*/
|
|
559
|
-
static fromNanoseconds(nanoseconds: bigint):
|
|
576
|
+
static fromNanoseconds(nanoseconds: bigint): DurationValue;
|
|
560
577
|
/**
|
|
561
|
-
* Create
|
|
578
|
+
* Create a duration from minutes
|
|
562
579
|
*/
|
|
563
|
-
static fromMinutes(minutes: number):
|
|
580
|
+
static fromMinutes(minutes: number): DurationValue;
|
|
564
581
|
/**
|
|
565
|
-
* Create
|
|
582
|
+
* Create a duration from hours
|
|
566
583
|
*/
|
|
567
|
-
static fromHours(hours: number):
|
|
584
|
+
static fromHours(hours: number): DurationValue;
|
|
568
585
|
/**
|
|
569
|
-
* Create
|
|
586
|
+
* Create a duration from days
|
|
570
587
|
*/
|
|
571
|
-
static fromDays(days: number):
|
|
588
|
+
static fromDays(days: number): DurationValue;
|
|
572
589
|
/**
|
|
573
|
-
* Create
|
|
590
|
+
* Create a duration from weeks
|
|
574
591
|
*/
|
|
575
|
-
static fromWeeks(weeks: number):
|
|
592
|
+
static fromWeeks(weeks: number): DurationValue;
|
|
576
593
|
/**
|
|
577
|
-
* Create
|
|
594
|
+
* Create a duration from months
|
|
578
595
|
*/
|
|
579
|
-
static fromMonths(months: number):
|
|
596
|
+
static fromMonths(months: number): DurationValue;
|
|
580
597
|
/**
|
|
581
|
-
* Create
|
|
598
|
+
* Create a duration from years
|
|
582
599
|
*/
|
|
583
|
-
static fromYears(years: number):
|
|
600
|
+
static fromYears(years: number): DurationValue;
|
|
584
601
|
/**
|
|
585
|
-
* Create a zero
|
|
602
|
+
* Create a zero duration
|
|
586
603
|
*/
|
|
587
|
-
static zero():
|
|
604
|
+
static zero(): DurationValue;
|
|
588
605
|
/**
|
|
589
|
-
* Get default
|
|
606
|
+
* Get default duration (zero)
|
|
590
607
|
*/
|
|
591
|
-
static default():
|
|
608
|
+
static default(): DurationValue;
|
|
592
609
|
/**
|
|
593
|
-
* Parse
|
|
610
|
+
* Parse a duration string in ISO 8601 duration format
|
|
594
611
|
*/
|
|
595
|
-
static parse(str: string):
|
|
612
|
+
static parse(str: string): DurationValue;
|
|
596
613
|
/**
|
|
597
614
|
* Get total seconds (truncated)
|
|
598
615
|
*/
|
|
@@ -622,21 +639,21 @@ declare class IntervalValue implements Value {
|
|
|
622
639
|
*/
|
|
623
640
|
getNanos(): bigint | undefined;
|
|
624
641
|
/**
|
|
625
|
-
* Check if
|
|
642
|
+
* Check if duration is positive (any component > 0)
|
|
626
643
|
*/
|
|
627
644
|
isPositive(): boolean;
|
|
628
645
|
/**
|
|
629
|
-
* Check if
|
|
646
|
+
* Check if duration is negative (any component < 0)
|
|
630
647
|
*/
|
|
631
648
|
isNegative(): boolean;
|
|
632
649
|
/**
|
|
633
|
-
* Get absolute value of
|
|
650
|
+
* Get absolute value of duration
|
|
634
651
|
*/
|
|
635
|
-
abs():
|
|
652
|
+
abs(): DurationValue;
|
|
636
653
|
/**
|
|
637
|
-
* Negate the
|
|
654
|
+
* Negate the duration
|
|
638
655
|
*/
|
|
639
|
-
negate():
|
|
656
|
+
negate(): DurationValue;
|
|
640
657
|
/**
|
|
641
658
|
* Format as ISO 8601 duration string
|
|
642
659
|
*/
|
|
@@ -659,7 +676,7 @@ declare class IntervalValue implements Value {
|
|
|
659
676
|
*/
|
|
660
677
|
private static parseDuration;
|
|
661
678
|
/**
|
|
662
|
-
* Compare two
|
|
679
|
+
* Compare two durations for equality
|
|
663
680
|
*/
|
|
664
681
|
equals(other: Value): boolean;
|
|
665
682
|
encode(): TypeValuePair;
|
|
@@ -1063,7 +1080,7 @@ declare class IdentityIdValue implements Value {
|
|
|
1063
1080
|
* See license.md file for full license text
|
|
1064
1081
|
*/
|
|
1065
1082
|
|
|
1066
|
-
type Type = "Blob" | "Boolean" | "Float4" | "Float8" | "Int1" | "Int2" | "Int4" | "Int8" | "Int16" | "Uint1" | "Uint2" | "Uint4" | "Uint8" | "Uint16" | "Utf8" | "Date" | "DateTime" | "Time" | "
|
|
1083
|
+
type Type = "Blob" | "Boolean" | "Decimal" | "Float4" | "Float8" | "Int1" | "Int2" | "Int4" | "Int8" | "Int16" | "Uint1" | "Uint2" | "Uint4" | "Uint8" | "Uint16" | "Utf8" | "Date" | "DateTime" | "Time" | "Duration" | "Uuid4" | "Uuid7" | "Undefined" | "RowNumber" | "IdentityId";
|
|
1067
1084
|
interface TypeValuePair {
|
|
1068
1085
|
type: Type;
|
|
1069
1086
|
value: string;
|
|
@@ -1088,8 +1105,8 @@ declare function decode(pair: TypeValuePair): Value;
|
|
|
1088
1105
|
* See license.md file for full license text
|
|
1089
1106
|
*/
|
|
1090
1107
|
|
|
1091
|
-
type PrimitiveToTS<T extends Type> = T extends 'Blob' ? Uint8Array : T extends 'Boolean' ? boolean : T extends 'Float4' ? number : T extends 'Float8' ? number : T extends 'Int1' ? number : T extends 'Int2' ? number : T extends 'Int4' ? number : T extends 'Int8' ? bigint : T extends 'Int16' ? bigint : T extends 'Uint1' ? number : T extends 'Uint2' ? number : T extends 'Uint4' ? number : T extends 'Uint8' ? bigint : T extends 'Uint16' ? bigint : T extends 'Utf8' ? string : T extends 'Date' ? Date : T extends 'DateTime' ? Date : T extends 'Time' ? string : T extends '
|
|
1092
|
-
type PrimitiveToValue<T extends Type> = T extends 'Blob' ? BlobValue : T extends 'Boolean' ? BooleanValue : T extends 'Float4' ? Float4Value : T extends 'Float8' ? Float8Value : T extends 'Int1' ? Int1Value : T extends 'Int2' ? Int2Value : T extends 'Int4' ? Int4Value : T extends 'Int8' ? Int8Value : T extends 'Int16' ? Int16Value : T extends 'Uint1' ? Uint1Value : T extends 'Uint2' ? Uint2Value : T extends 'Uint4' ? Uint4Value : T extends 'Uint8' ? Uint8Value : T extends 'Uint16' ? Uint16Value : T extends 'Utf8' ? Utf8Value : T extends 'Date' ? DateValue : T extends 'DateTime' ? DateTimeValue : T extends 'Time' ? TimeValue : T extends '
|
|
1108
|
+
type PrimitiveToTS<T extends Type> = T extends 'Blob' ? Uint8Array : T extends 'Boolean' ? boolean : T extends 'Decimal' ? string : T extends 'Float4' ? number : T extends 'Float8' ? number : T extends 'Int1' ? number : T extends 'Int2' ? number : T extends 'Int4' ? number : T extends 'Int8' ? bigint : T extends 'Int16' ? bigint : T extends 'Uint1' ? number : T extends 'Uint2' ? number : T extends 'Uint4' ? number : T extends 'Uint8' ? bigint : T extends 'Uint16' ? bigint : T extends 'Utf8' ? string : T extends 'Date' ? Date : T extends 'DateTime' ? Date : T extends 'Time' ? string : T extends 'Duration' ? string : T extends 'Uuid4' ? string : T extends 'Uuid7' ? string : T extends 'Undefined' ? undefined : T extends 'RowNumber' ? bigint : T extends 'IdentityId' ? string : never;
|
|
1109
|
+
type PrimitiveToValue<T extends Type> = T extends 'Blob' ? BlobValue : T extends 'Boolean' ? BooleanValue : T extends 'Decimal' ? DecimalValue : T extends 'Float4' ? Float4Value : T extends 'Float8' ? Float8Value : T extends 'Int1' ? Int1Value : T extends 'Int2' ? Int2Value : T extends 'Int4' ? Int4Value : T extends 'Int8' ? Int8Value : T extends 'Int16' ? Int16Value : T extends 'Uint1' ? Uint1Value : T extends 'Uint2' ? Uint2Value : T extends 'Uint4' ? Uint4Value : T extends 'Uint8' ? Uint8Value : T extends 'Uint16' ? Uint16Value : T extends 'Utf8' ? Utf8Value : T extends 'Date' ? DateValue : T extends 'DateTime' ? DateTimeValue : T extends 'Time' ? TimeValue : T extends 'Duration' ? DurationValue : T extends 'Uuid4' ? Uuid4Value : T extends 'Uuid7' ? Uuid7Value : T extends 'Undefined' ? UndefinedValue : T extends 'RowNumber' ? RowNumberValue : T extends 'IdentityId' ? IdentityIdValue : never;
|
|
1093
1110
|
type InferSchema<S> = S extends PrimitiveSchemaNode<infer T> ? T extends Type ? PrimitiveToTS<T> : never : S extends ValueSchemaNode<infer T> ? T extends Type ? PrimitiveToValue<T> : never : S extends ObjectSchemaNode<infer P> ? {
|
|
1094
1111
|
[K in keyof P]: InferSchema<P[K]>;
|
|
1095
1112
|
} : S extends ArraySchemaNode<infer T> ? InferSchema<T>[] : S extends OptionalSchemaNode<infer T> ? InferSchema<T> | undefined : never;
|
|
@@ -1107,6 +1124,7 @@ declare class SchemaBuilder {
|
|
|
1107
1124
|
static blob(): PrimitiveSchemaNode<'Blob'>;
|
|
1108
1125
|
static bool(): PrimitiveSchemaNode<'Boolean'>;
|
|
1109
1126
|
static boolean(): PrimitiveSchemaNode<'Boolean'>;
|
|
1127
|
+
static decimal(): PrimitiveSchemaNode<'Decimal'>;
|
|
1110
1128
|
static float4(): PrimitiveSchemaNode<'Float4'>;
|
|
1111
1129
|
static float8(): PrimitiveSchemaNode<'Float8'>;
|
|
1112
1130
|
static float(): PrimitiveSchemaNode<'Float8'>;
|
|
@@ -1128,7 +1146,7 @@ declare class SchemaBuilder {
|
|
|
1128
1146
|
static date(): PrimitiveSchemaNode<'Date'>;
|
|
1129
1147
|
static datetime(): PrimitiveSchemaNode<'DateTime'>;
|
|
1130
1148
|
static time(): PrimitiveSchemaNode<'Time'>;
|
|
1131
|
-
static
|
|
1149
|
+
static duration(): PrimitiveSchemaNode<'Duration'>;
|
|
1132
1150
|
static uuid4(): PrimitiveSchemaNode<'Uuid4'>;
|
|
1133
1151
|
static uuid7(): PrimitiveSchemaNode<'Uuid7'>;
|
|
1134
1152
|
static uuid(): PrimitiveSchemaNode<'Uuid7'>;
|
|
@@ -1140,6 +1158,7 @@ declare class SchemaBuilder {
|
|
|
1140
1158
|
static optional<T extends SchemaNode>(schema: T): OptionalSchemaNode<T>;
|
|
1141
1159
|
static number(): PrimitiveSchemaNode<'Float8'>;
|
|
1142
1160
|
static booleanValue(): ValueSchemaNode<'Boolean'>;
|
|
1161
|
+
static decimalValue(): ValueSchemaNode<'Decimal'>;
|
|
1143
1162
|
static int1Value(): ValueSchemaNode<'Int1'>;
|
|
1144
1163
|
static int2Value(): ValueSchemaNode<'Int2'>;
|
|
1145
1164
|
static int4Value(): ValueSchemaNode<'Int4'>;
|
|
@@ -1156,7 +1175,7 @@ declare class SchemaBuilder {
|
|
|
1156
1175
|
static dateValue(): ValueSchemaNode<'Date'>;
|
|
1157
1176
|
static dateTimeValue(): ValueSchemaNode<'DateTime'>;
|
|
1158
1177
|
static timeValue(): ValueSchemaNode<'Time'>;
|
|
1159
|
-
static
|
|
1178
|
+
static durationValue(): ValueSchemaNode<'Duration'>;
|
|
1160
1179
|
static uuid4Value(): ValueSchemaNode<'Uuid4'>;
|
|
1161
1180
|
static uuid7Value(): ValueSchemaNode<'Uuid7'>;
|
|
1162
1181
|
static undefinedValue(): ValueSchemaNode<'Undefined'>;
|
|
@@ -1277,4 +1296,4 @@ type SingleFrameResult<S extends SchemaNode> = InferSchema<S>[];
|
|
|
1277
1296
|
*/
|
|
1278
1297
|
declare function asFrameResults<S extends readonly SchemaNode[]>(results: any): FrameResults<S>;
|
|
1279
1298
|
|
|
1280
|
-
export { type ArraySchemaNode, BlobValue, BooleanValue, type Column, DateTimeValue, DateValue, type Diagnostic, type DiagnosticColumn, type ErrorResponse, Float4Value, Float8Value, type Fragment, type Frame, type FrameResults, IdentityIdValue, type InferSchema, type InferSchemas, Int16Value, Int1Value, Int2Value, Int4Value, Int8Value,
|
|
1299
|
+
export { type ArraySchemaNode, BlobValue, BooleanValue, type Column, DateTimeValue, DateValue, DecimalValue, type Diagnostic, type DiagnosticColumn, DurationValue, type ErrorResponse, Float4Value, Float8Value, type Fragment, type Frame, type FrameResults, IdentityIdValue, type InferSchema, type InferSchemas, Int16Value, Int1Value, Int2Value, Int4Value, Int8Value, type ObjectSchemaNode, type OptionalSchemaNode, type Params, type PrimitiveSchemaNode, type PrimitiveToTS, type PrimitiveToValue, ReifyError, RowNumberValue, Schema, SchemaBuilder, type SchemaNode, type SingleFrameResult, TimeValue, type Type, type TypeValuePair, UNDEFINED_VALUE, Uint16Value, Uint1Value, Uint2Value, Uint4Value, Uint8Value, UndefinedValue, Utf8Value, Uuid4Value, Uuid7Value, Value, type ValueSchemaNode, asFrameResults, decode, parseValue, validateSchema };
|
package/dist/index.js
CHANGED
|
@@ -1051,6 +1051,46 @@ var DateTimeValue = class _DateTimeValue {
|
|
|
1051
1051
|
}
|
|
1052
1052
|
};
|
|
1053
1053
|
|
|
1054
|
+
// src/value/decimal.ts
|
|
1055
|
+
var DecimalValue = class _DecimalValue {
|
|
1056
|
+
constructor(value) {
|
|
1057
|
+
this.type = "Decimal";
|
|
1058
|
+
if (value !== void 0) {
|
|
1059
|
+
if (typeof value !== "string") {
|
|
1060
|
+
throw new Error(`Decimal value must be a string, got ${typeof value}`);
|
|
1061
|
+
}
|
|
1062
|
+
this.value = value;
|
|
1063
|
+
} else {
|
|
1064
|
+
this.value = void 0;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
static parse(str) {
|
|
1068
|
+
if (str === UNDEFINED_VALUE) {
|
|
1069
|
+
return new _DecimalValue(void 0);
|
|
1070
|
+
}
|
|
1071
|
+
return new _DecimalValue(str);
|
|
1072
|
+
}
|
|
1073
|
+
valueOf() {
|
|
1074
|
+
return this.value;
|
|
1075
|
+
}
|
|
1076
|
+
toString() {
|
|
1077
|
+
return this.value === void 0 ? "undefined" : this.value;
|
|
1078
|
+
}
|
|
1079
|
+
equals(other) {
|
|
1080
|
+
if (other.type !== this.type) {
|
|
1081
|
+
return false;
|
|
1082
|
+
}
|
|
1083
|
+
const otherDecimal = other;
|
|
1084
|
+
return this.value === otherDecimal.value;
|
|
1085
|
+
}
|
|
1086
|
+
encode() {
|
|
1087
|
+
return {
|
|
1088
|
+
type: this.type,
|
|
1089
|
+
value: this.value === void 0 ? UNDEFINED_VALUE : this.toString()
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1054
1094
|
// src/value/float4.ts
|
|
1055
1095
|
var _Float4Value = class _Float4Value {
|
|
1056
1096
|
constructor(value) {
|
|
@@ -1450,16 +1490,16 @@ _Int16Value.MIN_VALUE = BigInt("-170141183460469231731687303715884105728");
|
|
|
1450
1490
|
_Int16Value.MAX_VALUE = BigInt("170141183460469231731687303715884105727");
|
|
1451
1491
|
var Int16Value = _Int16Value;
|
|
1452
1492
|
|
|
1453
|
-
// src/value/
|
|
1454
|
-
var
|
|
1493
|
+
// src/value/duration.ts
|
|
1494
|
+
var DurationValue = class _DurationValue {
|
|
1455
1495
|
// all time components as nanoseconds
|
|
1456
1496
|
constructor(value) {
|
|
1457
|
-
this.type = "
|
|
1497
|
+
this.type = "Duration";
|
|
1458
1498
|
if (value !== void 0) {
|
|
1459
1499
|
if (typeof value === "string") {
|
|
1460
|
-
const parsed =
|
|
1500
|
+
const parsed = _DurationValue.parseDuration(value);
|
|
1461
1501
|
if (!parsed) {
|
|
1462
|
-
throw new Error(`Invalid
|
|
1502
|
+
throw new Error(`Invalid duration string: ${value}`);
|
|
1463
1503
|
}
|
|
1464
1504
|
this.months = parsed.months;
|
|
1465
1505
|
this.days = parsed.days;
|
|
@@ -1469,7 +1509,7 @@ var IntervalValue = class _IntervalValue {
|
|
|
1469
1509
|
this.days = value.days;
|
|
1470
1510
|
this.nanos = value.nanos;
|
|
1471
1511
|
} else {
|
|
1472
|
-
throw new Error(`
|
|
1512
|
+
throw new Error(`Duration value must be an object or string, got ${typeof value}`);
|
|
1473
1513
|
}
|
|
1474
1514
|
} else {
|
|
1475
1515
|
this.months = void 0;
|
|
@@ -1478,96 +1518,96 @@ var IntervalValue = class _IntervalValue {
|
|
|
1478
1518
|
}
|
|
1479
1519
|
}
|
|
1480
1520
|
/**
|
|
1481
|
-
* Create a new
|
|
1521
|
+
* Create a new duration from months, days, and nanoseconds
|
|
1482
1522
|
*/
|
|
1483
1523
|
static new(months, days, nanos) {
|
|
1484
|
-
return new
|
|
1524
|
+
return new _DurationValue({ months, days, nanos });
|
|
1485
1525
|
}
|
|
1486
1526
|
/**
|
|
1487
|
-
* Create
|
|
1527
|
+
* Create a duration from seconds
|
|
1488
1528
|
*/
|
|
1489
1529
|
static fromSeconds(seconds) {
|
|
1490
|
-
return new
|
|
1530
|
+
return new _DurationValue({ months: 0, days: 0, nanos: BigInt(seconds) * 1000000000n });
|
|
1491
1531
|
}
|
|
1492
1532
|
/**
|
|
1493
|
-
* Create
|
|
1533
|
+
* Create a duration from milliseconds
|
|
1494
1534
|
*/
|
|
1495
1535
|
static fromMilliseconds(milliseconds) {
|
|
1496
|
-
return new
|
|
1536
|
+
return new _DurationValue({ months: 0, days: 0, nanos: BigInt(milliseconds) * 1000000n });
|
|
1497
1537
|
}
|
|
1498
1538
|
/**
|
|
1499
|
-
* Create
|
|
1539
|
+
* Create a duration from microseconds
|
|
1500
1540
|
*/
|
|
1501
1541
|
static fromMicroseconds(microseconds) {
|
|
1502
|
-
return new
|
|
1542
|
+
return new _DurationValue({ months: 0, days: 0, nanos: BigInt(microseconds) * 1000n });
|
|
1503
1543
|
}
|
|
1504
1544
|
/**
|
|
1505
|
-
* Create
|
|
1545
|
+
* Create a duration from nanoseconds
|
|
1506
1546
|
*/
|
|
1507
1547
|
static fromNanoseconds(nanoseconds) {
|
|
1508
|
-
return new
|
|
1548
|
+
return new _DurationValue({ months: 0, days: 0, nanos: nanoseconds });
|
|
1509
1549
|
}
|
|
1510
1550
|
/**
|
|
1511
|
-
* Create
|
|
1551
|
+
* Create a duration from minutes
|
|
1512
1552
|
*/
|
|
1513
1553
|
static fromMinutes(minutes) {
|
|
1514
|
-
return new
|
|
1554
|
+
return new _DurationValue({ months: 0, days: 0, nanos: BigInt(minutes) * 60n * 1000000000n });
|
|
1515
1555
|
}
|
|
1516
1556
|
/**
|
|
1517
|
-
* Create
|
|
1557
|
+
* Create a duration from hours
|
|
1518
1558
|
*/
|
|
1519
1559
|
static fromHours(hours) {
|
|
1520
|
-
return new
|
|
1560
|
+
return new _DurationValue({ months: 0, days: 0, nanos: BigInt(hours) * 60n * 60n * 1000000000n });
|
|
1521
1561
|
}
|
|
1522
1562
|
/**
|
|
1523
|
-
* Create
|
|
1563
|
+
* Create a duration from days
|
|
1524
1564
|
*/
|
|
1525
1565
|
static fromDays(days) {
|
|
1526
|
-
return new
|
|
1566
|
+
return new _DurationValue({ months: 0, days, nanos: 0n });
|
|
1527
1567
|
}
|
|
1528
1568
|
/**
|
|
1529
|
-
* Create
|
|
1569
|
+
* Create a duration from weeks
|
|
1530
1570
|
*/
|
|
1531
1571
|
static fromWeeks(weeks) {
|
|
1532
|
-
return new
|
|
1572
|
+
return new _DurationValue({ months: 0, days: weeks * 7, nanos: 0n });
|
|
1533
1573
|
}
|
|
1534
1574
|
/**
|
|
1535
|
-
* Create
|
|
1575
|
+
* Create a duration from months
|
|
1536
1576
|
*/
|
|
1537
1577
|
static fromMonths(months) {
|
|
1538
|
-
return new
|
|
1578
|
+
return new _DurationValue({ months, days: 0, nanos: 0n });
|
|
1539
1579
|
}
|
|
1540
1580
|
/**
|
|
1541
|
-
* Create
|
|
1581
|
+
* Create a duration from years
|
|
1542
1582
|
*/
|
|
1543
1583
|
static fromYears(years) {
|
|
1544
|
-
return new
|
|
1584
|
+
return new _DurationValue({ months: years * 12, days: 0, nanos: 0n });
|
|
1545
1585
|
}
|
|
1546
1586
|
/**
|
|
1547
|
-
* Create a zero
|
|
1587
|
+
* Create a zero duration
|
|
1548
1588
|
*/
|
|
1549
1589
|
static zero() {
|
|
1550
|
-
return new
|
|
1590
|
+
return new _DurationValue({ months: 0, days: 0, nanos: 0n });
|
|
1551
1591
|
}
|
|
1552
1592
|
/**
|
|
1553
|
-
* Get default
|
|
1593
|
+
* Get default duration (zero)
|
|
1554
1594
|
*/
|
|
1555
1595
|
static default() {
|
|
1556
|
-
return
|
|
1596
|
+
return _DurationValue.zero();
|
|
1557
1597
|
}
|
|
1558
1598
|
/**
|
|
1559
|
-
* Parse
|
|
1599
|
+
* Parse a duration string in ISO 8601 duration format
|
|
1560
1600
|
*/
|
|
1561
1601
|
static parse(str) {
|
|
1562
1602
|
const trimmed = str.trim();
|
|
1563
1603
|
if (trimmed === "" || trimmed === UNDEFINED_VALUE) {
|
|
1564
|
-
return new
|
|
1604
|
+
return new _DurationValue(void 0);
|
|
1565
1605
|
}
|
|
1566
|
-
const parsed =
|
|
1606
|
+
const parsed = _DurationValue.parseDuration(trimmed);
|
|
1567
1607
|
if (!parsed) {
|
|
1568
|
-
throw new Error(`Cannot parse "${str}" as
|
|
1608
|
+
throw new Error(`Cannot parse "${str}" as Duration`);
|
|
1569
1609
|
}
|
|
1570
|
-
return new
|
|
1610
|
+
return new _DurationValue({ months: parsed.months, days: parsed.days, nanos: parsed.nanos });
|
|
1571
1611
|
}
|
|
1572
1612
|
/**
|
|
1573
1613
|
* Get total seconds (truncated)
|
|
@@ -1615,7 +1655,7 @@ var IntervalValue = class _IntervalValue {
|
|
|
1615
1655
|
return this.nanos;
|
|
1616
1656
|
}
|
|
1617
1657
|
/**
|
|
1618
|
-
* Check if
|
|
1658
|
+
* Check if duration is positive (any component > 0)
|
|
1619
1659
|
*/
|
|
1620
1660
|
isPositive() {
|
|
1621
1661
|
if (this.months === void 0 || this.days === void 0 || this.nanos === void 0) {
|
|
@@ -1624,7 +1664,7 @@ var IntervalValue = class _IntervalValue {
|
|
|
1624
1664
|
return this.months > 0 || this.days > 0 || this.nanos > 0n;
|
|
1625
1665
|
}
|
|
1626
1666
|
/**
|
|
1627
|
-
* Check if
|
|
1667
|
+
* Check if duration is negative (any component < 0)
|
|
1628
1668
|
*/
|
|
1629
1669
|
isNegative() {
|
|
1630
1670
|
if (this.months === void 0 || this.days === void 0 || this.nanos === void 0) {
|
|
@@ -1633,26 +1673,26 @@ var IntervalValue = class _IntervalValue {
|
|
|
1633
1673
|
return this.months < 0 || this.days < 0 || this.nanos < 0n;
|
|
1634
1674
|
}
|
|
1635
1675
|
/**
|
|
1636
|
-
* Get absolute value of
|
|
1676
|
+
* Get absolute value of duration
|
|
1637
1677
|
*/
|
|
1638
1678
|
abs() {
|
|
1639
1679
|
if (this.months === void 0 || this.days === void 0 || this.nanos === void 0) {
|
|
1640
|
-
return new
|
|
1680
|
+
return new _DurationValue(void 0);
|
|
1641
1681
|
}
|
|
1642
|
-
return new
|
|
1682
|
+
return new _DurationValue({
|
|
1643
1683
|
months: Math.abs(this.months),
|
|
1644
1684
|
days: Math.abs(this.days),
|
|
1645
1685
|
nanos: this.nanos < 0n ? -this.nanos : this.nanos
|
|
1646
1686
|
});
|
|
1647
1687
|
}
|
|
1648
1688
|
/**
|
|
1649
|
-
* Negate the
|
|
1689
|
+
* Negate the duration
|
|
1650
1690
|
*/
|
|
1651
1691
|
negate() {
|
|
1652
1692
|
if (this.months === void 0 || this.days === void 0 || this.nanos === void 0) {
|
|
1653
|
-
return new
|
|
1693
|
+
return new _DurationValue(void 0);
|
|
1654
1694
|
}
|
|
1655
|
-
return new
|
|
1695
|
+
return new _DurationValue({
|
|
1656
1696
|
months: -this.months,
|
|
1657
1697
|
days: -this.days,
|
|
1658
1698
|
nanos: -this.nanos
|
|
@@ -1767,17 +1807,17 @@ var IntervalValue = class _IntervalValue {
|
|
|
1767
1807
|
}
|
|
1768
1808
|
}
|
|
1769
1809
|
/**
|
|
1770
|
-
* Compare two
|
|
1810
|
+
* Compare two durations for equality
|
|
1771
1811
|
*/
|
|
1772
1812
|
equals(other) {
|
|
1773
1813
|
if (other.type !== this.type) {
|
|
1774
1814
|
return false;
|
|
1775
1815
|
}
|
|
1776
|
-
const
|
|
1777
|
-
if (this.months === void 0 ||
|
|
1778
|
-
return this.months ===
|
|
1816
|
+
const otherDuration = other;
|
|
1817
|
+
if (this.months === void 0 || otherDuration.months === void 0) {
|
|
1818
|
+
return this.months === otherDuration.months && this.days === otherDuration.days && this.nanos === otherDuration.nanos;
|
|
1779
1819
|
}
|
|
1780
|
-
return this.months ===
|
|
1820
|
+
return this.months === otherDuration.months && this.days === otherDuration.days && this.nanos === otherDuration.nanos;
|
|
1781
1821
|
}
|
|
1782
1822
|
encode() {
|
|
1783
1823
|
return {
|
|
@@ -2657,6 +2697,8 @@ function decode(pair) {
|
|
|
2657
2697
|
return DateValue.parse(pair.value);
|
|
2658
2698
|
case "DateTime":
|
|
2659
2699
|
return DateTimeValue.parse(pair.value);
|
|
2700
|
+
case "Decimal":
|
|
2701
|
+
return DecimalValue.parse(pair.value);
|
|
2660
2702
|
case "Float4":
|
|
2661
2703
|
return Float4Value.parse(pair.value);
|
|
2662
2704
|
case "Float8":
|
|
@@ -2671,8 +2713,8 @@ function decode(pair) {
|
|
|
2671
2713
|
return Int8Value.parse(pair.value);
|
|
2672
2714
|
case "Int16":
|
|
2673
2715
|
return Int16Value.parse(pair.value);
|
|
2674
|
-
case "
|
|
2675
|
-
return
|
|
2716
|
+
case "Duration":
|
|
2717
|
+
return DurationValue.parse(pair.value);
|
|
2676
2718
|
case "RowNumber":
|
|
2677
2719
|
return RowNumberValue.parse(pair.value);
|
|
2678
2720
|
case "Time":
|
|
@@ -2713,6 +2755,9 @@ var SchemaBuilder = class {
|
|
|
2713
2755
|
static boolean() {
|
|
2714
2756
|
return { kind: "primitive", type: "Boolean" };
|
|
2715
2757
|
}
|
|
2758
|
+
static decimal() {
|
|
2759
|
+
return { kind: "primitive", type: "Decimal" };
|
|
2760
|
+
}
|
|
2716
2761
|
static float4() {
|
|
2717
2762
|
return { kind: "primitive", type: "Float4" };
|
|
2718
2763
|
}
|
|
@@ -2776,8 +2821,8 @@ var SchemaBuilder = class {
|
|
|
2776
2821
|
static time() {
|
|
2777
2822
|
return { kind: "primitive", type: "Time" };
|
|
2778
2823
|
}
|
|
2779
|
-
static
|
|
2780
|
-
return { kind: "primitive", type: "
|
|
2824
|
+
static duration() {
|
|
2825
|
+
return { kind: "primitive", type: "Duration" };
|
|
2781
2826
|
}
|
|
2782
2827
|
static uuid4() {
|
|
2783
2828
|
return { kind: "primitive", type: "Uuid4" };
|
|
@@ -2812,6 +2857,9 @@ var SchemaBuilder = class {
|
|
|
2812
2857
|
static booleanValue() {
|
|
2813
2858
|
return { kind: "value", type: "Boolean" };
|
|
2814
2859
|
}
|
|
2860
|
+
static decimalValue() {
|
|
2861
|
+
return { kind: "value", type: "Decimal" };
|
|
2862
|
+
}
|
|
2815
2863
|
static int1Value() {
|
|
2816
2864
|
return { kind: "value", type: "Int1" };
|
|
2817
2865
|
}
|
|
@@ -2860,8 +2908,8 @@ var SchemaBuilder = class {
|
|
|
2860
2908
|
static timeValue() {
|
|
2861
2909
|
return { kind: "value", type: "Time" };
|
|
2862
2910
|
}
|
|
2863
|
-
static
|
|
2864
|
-
return { kind: "value", type: "
|
|
2911
|
+
static durationValue() {
|
|
2912
|
+
return { kind: "value", type: "Duration" };
|
|
2865
2913
|
}
|
|
2866
2914
|
static uuid4Value() {
|
|
2867
2915
|
return { kind: "value", type: "Uuid4" };
|
|
@@ -2923,8 +2971,8 @@ function createValueInstance(type, value) {
|
|
|
2923
2971
|
return new DateTimeValue(value);
|
|
2924
2972
|
case "Time":
|
|
2925
2973
|
return new TimeValue(value);
|
|
2926
|
-
case "
|
|
2927
|
-
return new
|
|
2974
|
+
case "Duration":
|
|
2975
|
+
return new DurationValue(value);
|
|
2928
2976
|
case "Uuid4":
|
|
2929
2977
|
return new Uuid4Value(value);
|
|
2930
2978
|
case "Uuid7":
|
|
@@ -2996,7 +3044,7 @@ function validateSchema(schema, value) {
|
|
|
2996
3044
|
return typeof value === "number" && value >= 0;
|
|
2997
3045
|
case "Utf8":
|
|
2998
3046
|
case "Time":
|
|
2999
|
-
case "
|
|
3047
|
+
case "Duration":
|
|
3000
3048
|
case "Uuid4":
|
|
3001
3049
|
case "Uuid7":
|
|
3002
3050
|
case "RowNumber":
|
|
@@ -3074,6 +3122,8 @@ export {
|
|
|
3074
3122
|
BooleanValue,
|
|
3075
3123
|
DateTimeValue,
|
|
3076
3124
|
DateValue,
|
|
3125
|
+
DecimalValue,
|
|
3126
|
+
DurationValue,
|
|
3077
3127
|
Float4Value,
|
|
3078
3128
|
Float8Value,
|
|
3079
3129
|
IdentityIdValue,
|
|
@@ -3082,7 +3132,6 @@ export {
|
|
|
3082
3132
|
Int2Value,
|
|
3083
3133
|
Int4Value,
|
|
3084
3134
|
Int8Value,
|
|
3085
|
-
IntervalValue,
|
|
3086
3135
|
ReifyError,
|
|
3087
3136
|
RowNumberValue,
|
|
3088
3137
|
Schema,
|