@reifydb/core 0.0.1 → 0.1.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.
- package/dist/constant.d.ts +7 -0
- package/dist/constant.d.ts.map +1 -0
- package/dist/constant.js +7 -0
- package/dist/constant.js.map +1 -0
- package/dist/decoder.d.ts +8 -0
- package/dist/decoder.d.ts.map +1 -0
- package/dist/decoder.js +59 -0
- package/dist/decoder.js.map +1 -0
- package/dist/index.d.ts +81 -56
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +190 -84
- package/dist/index.js.map +1 -1
- package/dist/schema/builder.d.ts +45 -0
- package/dist/schema/builder.d.ts.map +1 -0
- package/dist/schema/builder.js +114 -0
- package/dist/schema/builder.js.map +1 -0
- package/dist/schema/index.d.ts +11 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +12 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/inference.d.ts +16 -0
- package/dist/schema/inference.d.ts.map +1 -0
- package/dist/schema/inference.js +7 -0
- package/dist/schema/inference.js.map +1 -0
- package/dist/schema/parser.d.ts +8 -0
- package/dist/schema/parser.d.ts.map +1 -0
- package/dist/schema/parser.js +96 -0
- package/dist/schema/parser.js.map +1 -0
- package/dist/schema/simple-test.d.ts +7 -0
- package/dist/schema/simple-test.d.ts.map +1 -0
- package/dist/schema/simple-test.js +26 -0
- package/dist/schema/simple-test.js.map +1 -0
- package/dist/schema/test-refactor.d.ts +7 -0
- package/dist/schema/test-refactor.d.ts.map +1 -0
- package/dist/schema/test-refactor.js +97 -0
- package/dist/schema/test-refactor.js.map +1 -0
- package/dist/schema/types.d.ts +27 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +7 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/schema/validator.d.ts +8 -0
- package/dist/schema/validator.d.ts.map +1 -0
- package/dist/schema/validator.js +79 -0
- package/dist/schema/validator.js.map +1 -0
- package/dist/value/blob.d.ts +85 -0
- package/dist/value/blob.d.ts.map +1 -0
- package/dist/value/blob.js +255 -0
- package/dist/value/blob.js.map +1 -0
- package/dist/value/bool.d.ts +16 -0
- package/dist/value/bool.d.ts.map +1 -0
- package/dist/value/bool.js +46 -0
- package/dist/value/bool.js.map +1 -0
- package/dist/value/date.d.ts +71 -0
- package/dist/value/date.d.ts.map +1 -0
- package/dist/value/date.js +261 -0
- package/dist/value/date.js.map +1 -0
- package/dist/value/datetime.d.ts +99 -0
- package/dist/value/datetime.d.ts.map +1 -0
- package/dist/value/datetime.js +401 -0
- package/dist/value/datetime.js.map +1 -0
- package/dist/value/float4.d.ts +19 -0
- package/dist/value/float4.d.ts.map +1 -0
- package/dist/value/float4.js +68 -0
- package/dist/value/float4.js.map +1 -0
- package/dist/value/float8.d.ts +16 -0
- package/dist/value/float8.d.ts.map +1 -0
- package/dist/value/float8.js +44 -0
- package/dist/value/float8.js.map +1 -0
- package/dist/value/index.d.ts +38 -0
- package/dist/value/index.d.ts.map +1 -0
- package/dist/value/index.js +31 -0
- package/dist/value/index.js.map +1 -0
- package/dist/value/int1.d.ts +18 -0
- package/dist/value/int1.d.ts.map +1 -0
- package/dist/value/int1.js +46 -0
- package/dist/value/int1.js.map +1 -0
- package/dist/value/int16.d.ts +18 -0
- package/dist/value/int16.d.ts.map +1 -0
- package/dist/value/int16.js +67 -0
- package/dist/value/int16.js.map +1 -0
- package/dist/value/int2.d.ts +18 -0
- package/dist/value/int2.d.ts.map +1 -0
- package/dist/value/int2.js +46 -0
- package/dist/value/int2.js.map +1 -0
- package/dist/value/int4.d.ts +18 -0
- package/dist/value/int4.d.ts.map +1 -0
- package/dist/value/int4.js +46 -0
- package/dist/value/int4.js.map +1 -0
- package/dist/value/int8.d.ts +18 -0
- package/dist/value/int8.d.ts.map +1 -0
- package/dist/value/int8.js +53 -0
- package/dist/value/int8.js.map +1 -0
- package/dist/value/interval.d.ts +144 -0
- package/dist/value/interval.d.ts.map +1 -0
- package/dist/value/interval.js +357 -0
- package/dist/value/interval.js.map +1 -0
- package/dist/value/rowid.d.ts +18 -0
- package/dist/value/rowid.d.ts.map +1 -0
- package/dist/value/rowid.js +53 -0
- package/dist/value/rowid.js.map +1 -0
- package/dist/value/time.d.ts +74 -0
- package/dist/value/time.d.ts.map +1 -0
- package/dist/value/time.js +214 -0
- package/dist/value/time.js.map +1 -0
- package/dist/value/uint1.d.ts +18 -0
- package/dist/value/uint1.d.ts.map +1 -0
- package/dist/value/uint1.js +46 -0
- package/dist/value/uint1.js.map +1 -0
- package/dist/value/uint16.d.ts +18 -0
- package/dist/value/uint16.d.ts.map +1 -0
- package/dist/value/uint16.js +67 -0
- package/dist/value/uint16.js.map +1 -0
- package/dist/value/uint2.d.ts +18 -0
- package/dist/value/uint2.d.ts.map +1 -0
- package/dist/value/uint2.js +46 -0
- package/dist/value/uint2.js.map +1 -0
- package/dist/value/uint4.d.ts +18 -0
- package/dist/value/uint4.d.ts.map +1 -0
- package/dist/value/uint4.js +46 -0
- package/dist/value/uint4.js.map +1 -0
- package/dist/value/uint8.d.ts +19 -0
- package/dist/value/uint8.d.ts.map +1 -0
- package/dist/value/uint8.js +58 -0
- package/dist/value/uint8.js.map +1 -0
- package/dist/value/undefined.d.ts +48 -0
- package/dist/value/undefined.d.ts.map +1 -0
- package/dist/value/undefined.js +77 -0
- package/dist/value/undefined.js.map +1 -0
- package/dist/value/utf8.d.ts +16 -0
- package/dist/value/utf8.d.ts.map +1 -0
- package/dist/value/utf8.js +39 -0
- package/dist/value/utf8.js.map +1 -0
- package/dist/value/uuid4.d.ts +69 -0
- package/dist/value/uuid4.d.ts.map +1 -0
- package/dist/value/uuid4.js +162 -0
- package/dist/value/uuid4.js.map +1 -0
- package/dist/value/uuid7.d.ts +74 -0
- package/dist/value/uuid7.d.ts.map +1 -0
- package/dist/value/uuid7.js +175 -0
- package/dist/value/uuid7.js.map +1 -0
- package/package.json +12 -11
package/dist/index.js
CHANGED
|
@@ -223,13 +223,13 @@ var BlobValue = class _BlobValue {
|
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
-
// src/value/
|
|
227
|
-
var
|
|
226
|
+
// src/value/boolean.ts
|
|
227
|
+
var BooleanValue = class _BooleanValue {
|
|
228
228
|
constructor(value) {
|
|
229
|
-
this.type = "
|
|
229
|
+
this.type = "Boolean";
|
|
230
230
|
if (value !== void 0) {
|
|
231
231
|
if (typeof value !== "boolean") {
|
|
232
|
-
throw new Error(`
|
|
232
|
+
throw new Error(`Boolean value must be a boolean, got ${typeof value}`);
|
|
233
233
|
}
|
|
234
234
|
this.value = value;
|
|
235
235
|
} else {
|
|
@@ -239,15 +239,15 @@ var BoolValue = class _BoolValue {
|
|
|
239
239
|
static parse(str) {
|
|
240
240
|
const trimmed = str.trim().toLowerCase();
|
|
241
241
|
if (trimmed === "" || trimmed === UNDEFINED_VALUE) {
|
|
242
|
-
return new
|
|
242
|
+
return new _BooleanValue(void 0);
|
|
243
243
|
}
|
|
244
244
|
if (trimmed === "true") {
|
|
245
|
-
return new
|
|
245
|
+
return new _BooleanValue(true);
|
|
246
246
|
}
|
|
247
247
|
if (trimmed === "false") {
|
|
248
|
-
return new
|
|
248
|
+
return new _BooleanValue(false);
|
|
249
249
|
}
|
|
250
|
-
throw new Error(`Cannot parse "${str}" as
|
|
250
|
+
throw new Error(`Cannot parse "${str}" as Boolean`);
|
|
251
251
|
}
|
|
252
252
|
valueOf() {
|
|
253
253
|
return this.value;
|
|
@@ -262,8 +262,8 @@ var BoolValue = class _BoolValue {
|
|
|
262
262
|
if (other.type !== this.type) {
|
|
263
263
|
return false;
|
|
264
264
|
}
|
|
265
|
-
const
|
|
266
|
-
return this.value ===
|
|
265
|
+
const otherBoolean = other;
|
|
266
|
+
return this.value === otherBoolean.value;
|
|
267
267
|
}
|
|
268
268
|
encode() {
|
|
269
269
|
return {
|
|
@@ -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
|
|
@@ -1661,7 +1701,7 @@ var IntervalValue = class _IntervalValue {
|
|
|
1661
1701
|
/**
|
|
1662
1702
|
* Format as ISO 8601 duration string
|
|
1663
1703
|
*/
|
|
1664
|
-
|
|
1704
|
+
toIsoString() {
|
|
1665
1705
|
if (this.months === void 0 || this.days === void 0 || this.nanos === void 0) {
|
|
1666
1706
|
return "undefined";
|
|
1667
1707
|
}
|
|
@@ -1709,6 +1749,60 @@ var IntervalValue = class _IntervalValue {
|
|
|
1709
1749
|
}
|
|
1710
1750
|
return result;
|
|
1711
1751
|
}
|
|
1752
|
+
/**
|
|
1753
|
+
* Format as human-readable duration string
|
|
1754
|
+
* Examples: "1 year 2 mons 3 days 04:05:06.789", "3 days", "00:00:01.5"
|
|
1755
|
+
*/
|
|
1756
|
+
toString() {
|
|
1757
|
+
if (this.months === void 0 || this.days === void 0 || this.nanos === void 0) {
|
|
1758
|
+
return "undefined";
|
|
1759
|
+
}
|
|
1760
|
+
if (this.months === 0 && this.days === 0 && this.nanos === 0n) {
|
|
1761
|
+
return "00:00:00";
|
|
1762
|
+
}
|
|
1763
|
+
const parts = [];
|
|
1764
|
+
const years = Math.floor(this.months / 12);
|
|
1765
|
+
const months = this.months % 12;
|
|
1766
|
+
if (years !== 0) {
|
|
1767
|
+
parts.push(years === 1 ? "1 year" : `${years} years`);
|
|
1768
|
+
}
|
|
1769
|
+
if (months !== 0) {
|
|
1770
|
+
parts.push(months === 1 ? "1 mon" : `${months} mons`);
|
|
1771
|
+
}
|
|
1772
|
+
const totalSeconds = this.nanos / 1000000000n;
|
|
1773
|
+
const remainingNanos = this.nanos % 1000000000n;
|
|
1774
|
+
const extraDays = totalSeconds / 86400n;
|
|
1775
|
+
const remainingSeconds = totalSeconds % 86400n;
|
|
1776
|
+
const displayDays = this.days + Number(extraDays);
|
|
1777
|
+
const hours = remainingSeconds / 3600n;
|
|
1778
|
+
const minutes = remainingSeconds % 3600n / 60n;
|
|
1779
|
+
const seconds = remainingSeconds % 60n;
|
|
1780
|
+
if (displayDays !== 0) {
|
|
1781
|
+
parts.push(displayDays === 1 ? "1 day" : `${displayDays} days`);
|
|
1782
|
+
}
|
|
1783
|
+
if (hours !== 0n || minutes !== 0n || seconds !== 0n || remainingNanos !== 0n || parts.length === 0) {
|
|
1784
|
+
const hoursStr = String(hours).padStart(2, "0");
|
|
1785
|
+
const minutesStr = String(minutes).padStart(2, "0");
|
|
1786
|
+
let secondsStr;
|
|
1787
|
+
if (remainingNanos !== 0n) {
|
|
1788
|
+
const fractional = Number(remainingNanos) / 1e9;
|
|
1789
|
+
const totalSecondsFloat = Number(seconds) + fractional;
|
|
1790
|
+
const formatted = totalSecondsFloat.toFixed(9).replace(/0+$/, "").replace(/\.$/, "");
|
|
1791
|
+
const dotIndex = formatted.indexOf(".");
|
|
1792
|
+
if (dotIndex >= 0) {
|
|
1793
|
+
const wholePart = formatted.substring(0, dotIndex).padStart(2, "0");
|
|
1794
|
+
const fractionalPart = formatted.substring(dotIndex);
|
|
1795
|
+
secondsStr = wholePart + fractionalPart;
|
|
1796
|
+
} else {
|
|
1797
|
+
secondsStr = formatted.padStart(2, "0");
|
|
1798
|
+
}
|
|
1799
|
+
} else {
|
|
1800
|
+
secondsStr = String(seconds).padStart(2, "0");
|
|
1801
|
+
}
|
|
1802
|
+
parts.push(`${hoursStr}:${minutesStr}:${secondsStr}`);
|
|
1803
|
+
}
|
|
1804
|
+
return parts.join(" ");
|
|
1805
|
+
}
|
|
1712
1806
|
valueOf() {
|
|
1713
1807
|
if (this.months === void 0 || this.days === void 0 || this.nanos === void 0) {
|
|
1714
1808
|
return void 0;
|
|
@@ -1767,22 +1861,25 @@ var IntervalValue = class _IntervalValue {
|
|
|
1767
1861
|
}
|
|
1768
1862
|
}
|
|
1769
1863
|
/**
|
|
1770
|
-
* Compare two
|
|
1864
|
+
* Compare two durations for equality
|
|
1771
1865
|
*/
|
|
1772
1866
|
equals(other) {
|
|
1773
1867
|
if (other.type !== this.type) {
|
|
1774
1868
|
return false;
|
|
1775
1869
|
}
|
|
1776
|
-
const
|
|
1777
|
-
if (this.months === void 0 ||
|
|
1778
|
-
return this.months ===
|
|
1870
|
+
const otherDuration = other;
|
|
1871
|
+
if (this.months === void 0 || otherDuration.months === void 0) {
|
|
1872
|
+
return this.months === otherDuration.months && this.days === otherDuration.days && this.nanos === otherDuration.nanos;
|
|
1779
1873
|
}
|
|
1780
|
-
return this.months ===
|
|
1874
|
+
return this.months === otherDuration.months && this.days === otherDuration.days && this.nanos === otherDuration.nanos;
|
|
1875
|
+
}
|
|
1876
|
+
toJSON() {
|
|
1877
|
+
return this.value === void 0 ? UNDEFINED_VALUE : this.toIsoString();
|
|
1781
1878
|
}
|
|
1782
1879
|
encode() {
|
|
1783
1880
|
return {
|
|
1784
1881
|
type: this.type,
|
|
1785
|
-
value: this.value === void 0 ? UNDEFINED_VALUE : this.
|
|
1882
|
+
value: this.value === void 0 ? UNDEFINED_VALUE : this.toIsoString()
|
|
1786
1883
|
};
|
|
1787
1884
|
}
|
|
1788
1885
|
};
|
|
@@ -2651,12 +2748,14 @@ function decode(pair) {
|
|
|
2651
2748
|
switch (pair.type) {
|
|
2652
2749
|
case "Blob":
|
|
2653
2750
|
return BlobValue.parse(pair.value);
|
|
2654
|
-
case "
|
|
2655
|
-
return
|
|
2751
|
+
case "Boolean":
|
|
2752
|
+
return BooleanValue.parse(pair.value);
|
|
2656
2753
|
case "Date":
|
|
2657
2754
|
return DateValue.parse(pair.value);
|
|
2658
2755
|
case "DateTime":
|
|
2659
2756
|
return DateTimeValue.parse(pair.value);
|
|
2757
|
+
case "Decimal":
|
|
2758
|
+
return DecimalValue.parse(pair.value);
|
|
2660
2759
|
case "Float4":
|
|
2661
2760
|
return Float4Value.parse(pair.value);
|
|
2662
2761
|
case "Float8":
|
|
@@ -2671,8 +2770,8 @@ function decode(pair) {
|
|
|
2671
2770
|
return Int8Value.parse(pair.value);
|
|
2672
2771
|
case "Int16":
|
|
2673
2772
|
return Int16Value.parse(pair.value);
|
|
2674
|
-
case "
|
|
2675
|
-
return
|
|
2773
|
+
case "Duration":
|
|
2774
|
+
return DurationValue.parse(pair.value);
|
|
2676
2775
|
case "RowNumber":
|
|
2677
2776
|
return RowNumberValue.parse(pair.value);
|
|
2678
2777
|
case "Time":
|
|
@@ -2708,10 +2807,13 @@ var SchemaBuilder = class {
|
|
|
2708
2807
|
return { kind: "primitive", type: "Blob" };
|
|
2709
2808
|
}
|
|
2710
2809
|
static bool() {
|
|
2711
|
-
return { kind: "primitive", type: "
|
|
2810
|
+
return { kind: "primitive", type: "Boolean" };
|
|
2712
2811
|
}
|
|
2713
2812
|
static boolean() {
|
|
2714
|
-
return { kind: "primitive", type: "
|
|
2813
|
+
return { kind: "primitive", type: "Boolean" };
|
|
2814
|
+
}
|
|
2815
|
+
static decimal() {
|
|
2816
|
+
return { kind: "primitive", type: "Decimal" };
|
|
2715
2817
|
}
|
|
2716
2818
|
static float4() {
|
|
2717
2819
|
return { kind: "primitive", type: "Float4" };
|
|
@@ -2776,8 +2878,8 @@ var SchemaBuilder = class {
|
|
|
2776
2878
|
static time() {
|
|
2777
2879
|
return { kind: "primitive", type: "Time" };
|
|
2778
2880
|
}
|
|
2779
|
-
static
|
|
2780
|
-
return { kind: "primitive", type: "
|
|
2881
|
+
static duration() {
|
|
2882
|
+
return { kind: "primitive", type: "Duration" };
|
|
2781
2883
|
}
|
|
2782
2884
|
static uuid4() {
|
|
2783
2885
|
return { kind: "primitive", type: "Uuid4" };
|
|
@@ -2809,8 +2911,11 @@ var SchemaBuilder = class {
|
|
|
2809
2911
|
static number() {
|
|
2810
2912
|
return { kind: "primitive", type: "Float8" };
|
|
2811
2913
|
}
|
|
2812
|
-
static
|
|
2813
|
-
return { kind: "value", type: "
|
|
2914
|
+
static booleanValue() {
|
|
2915
|
+
return { kind: "value", type: "Boolean" };
|
|
2916
|
+
}
|
|
2917
|
+
static decimalValue() {
|
|
2918
|
+
return { kind: "value", type: "Decimal" };
|
|
2814
2919
|
}
|
|
2815
2920
|
static int1Value() {
|
|
2816
2921
|
return { kind: "value", type: "Int1" };
|
|
@@ -2860,8 +2965,8 @@ var SchemaBuilder = class {
|
|
|
2860
2965
|
static timeValue() {
|
|
2861
2966
|
return { kind: "value", type: "Time" };
|
|
2862
2967
|
}
|
|
2863
|
-
static
|
|
2864
|
-
return { kind: "value", type: "
|
|
2968
|
+
static durationValue() {
|
|
2969
|
+
return { kind: "value", type: "Duration" };
|
|
2865
2970
|
}
|
|
2866
2971
|
static uuid4Value() {
|
|
2867
2972
|
return { kind: "value", type: "Uuid4" };
|
|
@@ -2889,8 +2994,8 @@ function createValueInstance(type, value) {
|
|
|
2889
2994
|
switch (type) {
|
|
2890
2995
|
case "Blob":
|
|
2891
2996
|
return new BlobValue(value);
|
|
2892
|
-
case "
|
|
2893
|
-
return new
|
|
2997
|
+
case "Boolean":
|
|
2998
|
+
return new BooleanValue(value);
|
|
2894
2999
|
case "Float4":
|
|
2895
3000
|
return new Float4Value(value);
|
|
2896
3001
|
case "Float8":
|
|
@@ -2923,8 +3028,8 @@ function createValueInstance(type, value) {
|
|
|
2923
3028
|
return new DateTimeValue(value);
|
|
2924
3029
|
case "Time":
|
|
2925
3030
|
return new TimeValue(value);
|
|
2926
|
-
case "
|
|
2927
|
-
return new
|
|
3031
|
+
case "Duration":
|
|
3032
|
+
return new DurationValue(value);
|
|
2928
3033
|
case "Uuid4":
|
|
2929
3034
|
return new Uuid4Value(value);
|
|
2930
3035
|
case "Uuid7":
|
|
@@ -2977,7 +3082,7 @@ function validateSchema(schema, value) {
|
|
|
2977
3082
|
return schemaType === "Undefined";
|
|
2978
3083
|
}
|
|
2979
3084
|
switch (schemaType) {
|
|
2980
|
-
case "
|
|
3085
|
+
case "Boolean":
|
|
2981
3086
|
return typeof value === "boolean";
|
|
2982
3087
|
case "Float4":
|
|
2983
3088
|
case "Float8":
|
|
@@ -2996,7 +3101,7 @@ function validateSchema(schema, value) {
|
|
|
2996
3101
|
return typeof value === "number" && value >= 0;
|
|
2997
3102
|
case "Utf8":
|
|
2998
3103
|
case "Time":
|
|
2999
|
-
case "
|
|
3104
|
+
case "Duration":
|
|
3000
3105
|
case "Uuid4":
|
|
3001
3106
|
case "Uuid7":
|
|
3002
3107
|
case "RowNumber":
|
|
@@ -3048,7 +3153,7 @@ var ReifyError = class extends Error {
|
|
|
3048
3153
|
this.code = diagnostic.code;
|
|
3049
3154
|
this.statement = diagnostic.statement;
|
|
3050
3155
|
this.column = diagnostic.column;
|
|
3051
|
-
this.
|
|
3156
|
+
this.fragment = diagnostic.fragment;
|
|
3052
3157
|
this.label = diagnostic.label;
|
|
3053
3158
|
this.help = diagnostic.help;
|
|
3054
3159
|
this.notes = diagnostic.notes ?? [];
|
|
@@ -3056,7 +3161,7 @@ var ReifyError = class extends Error {
|
|
|
3056
3161
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
3057
3162
|
}
|
|
3058
3163
|
toString() {
|
|
3059
|
-
const position = this.
|
|
3164
|
+
const position = this.fragment ? `line ${this.fragment.line}, offset ${this.fragment.column}` : "unknown position";
|
|
3060
3165
|
const notes = this.notes.length ? `
|
|
3061
3166
|
Notes:
|
|
3062
3167
|
- ${this.notes.join("\n- ")}` : "";
|
|
@@ -3071,9 +3176,11 @@ function asFrameResults(results) {
|
|
|
3071
3176
|
}
|
|
3072
3177
|
export {
|
|
3073
3178
|
BlobValue,
|
|
3074
|
-
|
|
3179
|
+
BooleanValue,
|
|
3075
3180
|
DateTimeValue,
|
|
3076
3181
|
DateValue,
|
|
3182
|
+
DecimalValue,
|
|
3183
|
+
DurationValue,
|
|
3077
3184
|
Float4Value,
|
|
3078
3185
|
Float8Value,
|
|
3079
3186
|
IdentityIdValue,
|
|
@@ -3082,7 +3189,6 @@ export {
|
|
|
3082
3189
|
Int2Value,
|
|
3083
3190
|
Int4Value,
|
|
3084
3191
|
Int8Value,
|
|
3085
|
-
IntervalValue,
|
|
3086
3192
|
ReifyError,
|
|
3087
3193
|
RowNumberValue,
|
|
3088
3194
|
Schema,
|