@reifydb/core 0.0.1-alpha.1 → 0.0.1-alpha.11

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.js CHANGED
@@ -223,13 +223,13 @@ var BlobValue = class _BlobValue {
223
223
  }
224
224
  };
225
225
 
226
- // src/value/bool.ts
227
- var BoolValue = class _BoolValue {
226
+ // src/value/boolean.ts
227
+ var BooleanValue = class _BooleanValue {
228
228
  constructor(value) {
229
- this.type = "Bool";
229
+ this.type = "Boolean";
230
230
  if (value !== void 0) {
231
231
  if (typeof value !== "boolean") {
232
- throw new Error(`Bool value must be a boolean, got ${typeof value}`);
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 _BoolValue(void 0);
242
+ return new _BooleanValue(void 0);
243
243
  }
244
244
  if (trimmed === "true") {
245
- return new _BoolValue(true);
245
+ return new _BooleanValue(true);
246
246
  }
247
247
  if (trimmed === "false") {
248
- return new _BoolValue(false);
248
+ return new _BooleanValue(false);
249
249
  }
250
- throw new Error(`Cannot parse "${str}" as Bool`);
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 otherBool = other;
266
- return this.value === otherBool.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/interval.ts
1454
- var IntervalValue = class _IntervalValue {
1493
+ // src/value/duration.ts
1494
+ var DurationValue = class _DurationValue {
1455
1495
  // all time components as nanoseconds
1456
1496
  constructor(value) {
1457
- this.type = "Interval";
1497
+ this.type = "Duration";
1458
1498
  if (value !== void 0) {
1459
1499
  if (typeof value === "string") {
1460
- const parsed = _IntervalValue.parseDuration(value);
1500
+ const parsed = _DurationValue.parseDuration(value);
1461
1501
  if (!parsed) {
1462
- throw new Error(`Invalid interval string: ${value}`);
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(`Interval value must be an object or string, got ${typeof value}`);
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 interval from months, days, and nanoseconds
1521
+ * Create a new duration from months, days, and nanoseconds
1482
1522
  */
1483
1523
  static new(months, days, nanos) {
1484
- return new _IntervalValue({ months, days, nanos });
1524
+ return new _DurationValue({ months, days, nanos });
1485
1525
  }
1486
1526
  /**
1487
- * Create an interval from seconds
1527
+ * Create a duration from seconds
1488
1528
  */
1489
1529
  static fromSeconds(seconds) {
1490
- return new _IntervalValue({ months: 0, days: 0, nanos: BigInt(seconds) * 1000000000n });
1530
+ return new _DurationValue({ months: 0, days: 0, nanos: BigInt(seconds) * 1000000000n });
1491
1531
  }
1492
1532
  /**
1493
- * Create an interval from milliseconds
1533
+ * Create a duration from milliseconds
1494
1534
  */
1495
1535
  static fromMilliseconds(milliseconds) {
1496
- return new _IntervalValue({ months: 0, days: 0, nanos: BigInt(milliseconds) * 1000000n });
1536
+ return new _DurationValue({ months: 0, days: 0, nanos: BigInt(milliseconds) * 1000000n });
1497
1537
  }
1498
1538
  /**
1499
- * Create an interval from microseconds
1539
+ * Create a duration from microseconds
1500
1540
  */
1501
1541
  static fromMicroseconds(microseconds) {
1502
- return new _IntervalValue({ months: 0, days: 0, nanos: BigInt(microseconds) * 1000n });
1542
+ return new _DurationValue({ months: 0, days: 0, nanos: BigInt(microseconds) * 1000n });
1503
1543
  }
1504
1544
  /**
1505
- * Create an interval from nanoseconds
1545
+ * Create a duration from nanoseconds
1506
1546
  */
1507
1547
  static fromNanoseconds(nanoseconds) {
1508
- return new _IntervalValue({ months: 0, days: 0, nanos: nanoseconds });
1548
+ return new _DurationValue({ months: 0, days: 0, nanos: nanoseconds });
1509
1549
  }
1510
1550
  /**
1511
- * Create an interval from minutes
1551
+ * Create a duration from minutes
1512
1552
  */
1513
1553
  static fromMinutes(minutes) {
1514
- return new _IntervalValue({ months: 0, days: 0, nanos: BigInt(minutes) * 60n * 1000000000n });
1554
+ return new _DurationValue({ months: 0, days: 0, nanos: BigInt(minutes) * 60n * 1000000000n });
1515
1555
  }
1516
1556
  /**
1517
- * Create an interval from hours
1557
+ * Create a duration from hours
1518
1558
  */
1519
1559
  static fromHours(hours) {
1520
- return new _IntervalValue({ months: 0, days: 0, nanos: BigInt(hours) * 60n * 60n * 1000000000n });
1560
+ return new _DurationValue({ months: 0, days: 0, nanos: BigInt(hours) * 60n * 60n * 1000000000n });
1521
1561
  }
1522
1562
  /**
1523
- * Create an interval from days
1563
+ * Create a duration from days
1524
1564
  */
1525
1565
  static fromDays(days) {
1526
- return new _IntervalValue({ months: 0, days, nanos: 0n });
1566
+ return new _DurationValue({ months: 0, days, nanos: 0n });
1527
1567
  }
1528
1568
  /**
1529
- * Create an interval from weeks
1569
+ * Create a duration from weeks
1530
1570
  */
1531
1571
  static fromWeeks(weeks) {
1532
- return new _IntervalValue({ months: 0, days: weeks * 7, nanos: 0n });
1572
+ return new _DurationValue({ months: 0, days: weeks * 7, nanos: 0n });
1533
1573
  }
1534
1574
  /**
1535
- * Create an interval from months
1575
+ * Create a duration from months
1536
1576
  */
1537
1577
  static fromMonths(months) {
1538
- return new _IntervalValue({ months, days: 0, nanos: 0n });
1578
+ return new _DurationValue({ months, days: 0, nanos: 0n });
1539
1579
  }
1540
1580
  /**
1541
- * Create an interval from years
1581
+ * Create a duration from years
1542
1582
  */
1543
1583
  static fromYears(years) {
1544
- return new _IntervalValue({ months: years * 12, days: 0, nanos: 0n });
1584
+ return new _DurationValue({ months: years * 12, days: 0, nanos: 0n });
1545
1585
  }
1546
1586
  /**
1547
- * Create a zero interval
1587
+ * Create a zero duration
1548
1588
  */
1549
1589
  static zero() {
1550
- return new _IntervalValue({ months: 0, days: 0, nanos: 0n });
1590
+ return new _DurationValue({ months: 0, days: 0, nanos: 0n });
1551
1591
  }
1552
1592
  /**
1553
- * Get default interval (zero)
1593
+ * Get default duration (zero)
1554
1594
  */
1555
1595
  static default() {
1556
- return _IntervalValue.zero();
1596
+ return _DurationValue.zero();
1557
1597
  }
1558
1598
  /**
1559
- * Parse an interval string in ISO 8601 duration format
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 _IntervalValue(void 0);
1604
+ return new _DurationValue(void 0);
1565
1605
  }
1566
- const parsed = _IntervalValue.parseDuration(trimmed);
1606
+ const parsed = _DurationValue.parseDuration(trimmed);
1567
1607
  if (!parsed) {
1568
- throw new Error(`Cannot parse "${str}" as Interval`);
1608
+ throw new Error(`Cannot parse "${str}" as Duration`);
1569
1609
  }
1570
- return new _IntervalValue({ months: parsed.months, days: parsed.days, nanos: parsed.nanos });
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 interval is positive (any component > 0)
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 interval is negative (any component < 0)
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 interval
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 _IntervalValue(void 0);
1680
+ return new _DurationValue(void 0);
1641
1681
  }
1642
- return new _IntervalValue({
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 interval
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 _IntervalValue(void 0);
1693
+ return new _DurationValue(void 0);
1654
1694
  }
1655
- return new _IntervalValue({
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 intervals for equality
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 otherInterval = other;
1777
- if (this.months === void 0 || otherInterval.months === void 0) {
1778
- return this.months === otherInterval.months && this.days === otherInterval.days && this.nanos === otherInterval.nanos;
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 === otherInterval.months && this.days === otherInterval.days && this.nanos === otherInterval.nanos;
1820
+ return this.months === otherDuration.months && this.days === otherDuration.days && this.nanos === otherDuration.nanos;
1781
1821
  }
1782
1822
  encode() {
1783
1823
  return {
@@ -2651,12 +2691,14 @@ function decode(pair) {
2651
2691
  switch (pair.type) {
2652
2692
  case "Blob":
2653
2693
  return BlobValue.parse(pair.value);
2654
- case "Bool":
2655
- return BoolValue.parse(pair.value);
2694
+ case "Boolean":
2695
+ return BooleanValue.parse(pair.value);
2656
2696
  case "Date":
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 "Interval":
2675
- return IntervalValue.parse(pair.value);
2716
+ case "Duration":
2717
+ return DurationValue.parse(pair.value);
2676
2718
  case "RowNumber":
2677
2719
  return RowNumberValue.parse(pair.value);
2678
2720
  case "Time":
@@ -2708,10 +2750,13 @@ var SchemaBuilder = class {
2708
2750
  return { kind: "primitive", type: "Blob" };
2709
2751
  }
2710
2752
  static bool() {
2711
- return { kind: "primitive", type: "Bool" };
2753
+ return { kind: "primitive", type: "Boolean" };
2712
2754
  }
2713
2755
  static boolean() {
2714
- return { kind: "primitive", type: "Bool" };
2756
+ return { kind: "primitive", type: "Boolean" };
2757
+ }
2758
+ static decimal() {
2759
+ return { kind: "primitive", type: "Decimal" };
2715
2760
  }
2716
2761
  static float4() {
2717
2762
  return { kind: "primitive", type: "Float4" };
@@ -2776,8 +2821,8 @@ var SchemaBuilder = class {
2776
2821
  static time() {
2777
2822
  return { kind: "primitive", type: "Time" };
2778
2823
  }
2779
- static interval() {
2780
- return { kind: "primitive", type: "Interval" };
2824
+ static duration() {
2825
+ return { kind: "primitive", type: "Duration" };
2781
2826
  }
2782
2827
  static uuid4() {
2783
2828
  return { kind: "primitive", type: "Uuid4" };
@@ -2809,8 +2854,11 @@ var SchemaBuilder = class {
2809
2854
  static number() {
2810
2855
  return { kind: "primitive", type: "Float8" };
2811
2856
  }
2812
- static boolValue() {
2813
- return { kind: "value", type: "Bool" };
2857
+ static booleanValue() {
2858
+ return { kind: "value", type: "Boolean" };
2859
+ }
2860
+ static decimalValue() {
2861
+ return { kind: "value", type: "Decimal" };
2814
2862
  }
2815
2863
  static int1Value() {
2816
2864
  return { kind: "value", type: "Int1" };
@@ -2860,8 +2908,8 @@ var SchemaBuilder = class {
2860
2908
  static timeValue() {
2861
2909
  return { kind: "value", type: "Time" };
2862
2910
  }
2863
- static intervalValue() {
2864
- return { kind: "value", type: "Interval" };
2911
+ static durationValue() {
2912
+ return { kind: "value", type: "Duration" };
2865
2913
  }
2866
2914
  static uuid4Value() {
2867
2915
  return { kind: "value", type: "Uuid4" };
@@ -2889,8 +2937,8 @@ function createValueInstance(type, value) {
2889
2937
  switch (type) {
2890
2938
  case "Blob":
2891
2939
  return new BlobValue(value);
2892
- case "Bool":
2893
- return new BoolValue(value);
2940
+ case "Boolean":
2941
+ return new BooleanValue(value);
2894
2942
  case "Float4":
2895
2943
  return new Float4Value(value);
2896
2944
  case "Float8":
@@ -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 "Interval":
2927
- return new IntervalValue(value);
2974
+ case "Duration":
2975
+ return new DurationValue(value);
2928
2976
  case "Uuid4":
2929
2977
  return new Uuid4Value(value);
2930
2978
  case "Uuid7":
@@ -2977,7 +3025,7 @@ function validateSchema(schema, value) {
2977
3025
  return schemaType === "Undefined";
2978
3026
  }
2979
3027
  switch (schemaType) {
2980
- case "Bool":
3028
+ case "Boolean":
2981
3029
  return typeof value === "boolean";
2982
3030
  case "Float4":
2983
3031
  case "Float8":
@@ -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 "Interval":
3047
+ case "Duration":
3000
3048
  case "Uuid4":
3001
3049
  case "Uuid7":
3002
3050
  case "RowNumber":
@@ -3048,7 +3096,7 @@ var ReifyError = class extends Error {
3048
3096
  this.code = diagnostic.code;
3049
3097
  this.statement = diagnostic.statement;
3050
3098
  this.column = diagnostic.column;
3051
- this.span = diagnostic.span;
3099
+ this.fragment = diagnostic.fragment;
3052
3100
  this.label = diagnostic.label;
3053
3101
  this.help = diagnostic.help;
3054
3102
  this.notes = diagnostic.notes ?? [];
@@ -3056,7 +3104,7 @@ var ReifyError = class extends Error {
3056
3104
  Object.setPrototypeOf(this, new.target.prototype);
3057
3105
  }
3058
3106
  toString() {
3059
- const position = this.span ? `line ${this.span.line}, offset ${this.span.offset}` : "unknown position";
3107
+ const position = this.fragment ? `line ${this.fragment.line}, offset ${this.fragment.column}` : "unknown position";
3060
3108
  const notes = this.notes.length ? `
3061
3109
  Notes:
3062
3110
  - ${this.notes.join("\n- ")}` : "";
@@ -3071,9 +3119,11 @@ function asFrameResults(results) {
3071
3119
  }
3072
3120
  export {
3073
3121
  BlobValue,
3074
- BoolValue,
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,