data-finder-ts 0.1.3 → 0.1.5

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.
Files changed (62) hide show
  1. package/README.md +17 -55
  2. package/dist/chunk-BGEX377Q.js +230 -0
  3. package/dist/chunk-BGEX377Q.js.map +1 -0
  4. package/dist/chunk-BKPWV3OF.js +962 -0
  5. package/dist/chunk-BKPWV3OF.js.map +1 -0
  6. package/dist/{chunk-EYXBYV2X.js → chunk-GPHWC533.js} +2 -2
  7. package/dist/chunk-KAK75RVS.js +198 -0
  8. package/dist/chunk-KAK75RVS.js.map +1 -0
  9. package/dist/chunk-MGEL5RWM.js +628 -0
  10. package/dist/chunk-MGEL5RWM.js.map +1 -0
  11. package/dist/chunk-PF6EJZHB.js +1015 -0
  12. package/dist/chunk-PF6EJZHB.js.map +1 -0
  13. package/dist/datafinder/attribute.cjs +595 -18
  14. package/dist/datafinder/attribute.cjs.map +1 -1
  15. package/dist/datafinder/attribute.d.cts +73 -10
  16. package/dist/datafinder/attribute.d.ts +73 -10
  17. package/dist/datafinder/attribute.js +2 -2
  18. package/dist/datafinder/runner.cjs +1589 -288
  19. package/dist/datafinder/runner.cjs.map +1 -1
  20. package/dist/datafinder/runner.d.cts +41 -7
  21. package/dist/datafinder/runner.d.ts +41 -7
  22. package/dist/datafinder/runner.js +12 -6
  23. package/dist/datafinder/sql-generator.cjs +1484 -281
  24. package/dist/datafinder/sql-generator.cjs.map +1 -1
  25. package/dist/datafinder/sql-generator.d.cts +19 -14
  26. package/dist/datafinder/sql-generator.d.ts +19 -14
  27. package/dist/datafinder/sql-generator.js +9 -7
  28. package/dist/datafinder/typed-attributes.cjs +856 -93
  29. package/dist/datafinder/typed-attributes.cjs.map +1 -1
  30. package/dist/datafinder/typed-attributes.d.cts +3 -135
  31. package/dist/datafinder/typed-attributes.d.ts +3 -135
  32. package/dist/datafinder/typed-attributes.js +3 -3
  33. package/dist/dialect-CogGPm_y.d.cts +38 -0
  34. package/dist/dialect-aaG1bDi5.d.ts +38 -0
  35. package/dist/index.cjs +2080 -480
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +119 -14
  38. package/dist/index.d.ts +119 -14
  39. package/dist/index.js +362 -12
  40. package/dist/index.js.map +1 -1
  41. package/dist/model/milestoning.cjs +529 -0
  42. package/dist/model/milestoning.cjs.map +1 -1
  43. package/dist/model/milestoning.js +2 -2
  44. package/dist/model/relational.cjs +608 -12
  45. package/dist/model/relational.cjs.map +1 -1
  46. package/dist/model/relational.d.cts +456 -47
  47. package/dist/model/relational.d.ts +456 -47
  48. package/dist/model/relational.js +61 -3
  49. package/dist/typed-attributes-CUTf_6Ru.d.ts +328 -0
  50. package/dist/typed-attributes-CdWXq_78.d.cts +328 -0
  51. package/package.json +5 -2
  52. package/dist/chunk-3SSWFES4.js +0 -448
  53. package/dist/chunk-3SSWFES4.js.map +0 -1
  54. package/dist/chunk-5K2Z3YDY.js +0 -393
  55. package/dist/chunk-5K2Z3YDY.js.map +0 -1
  56. package/dist/chunk-6QTCGJWX.js +0 -98
  57. package/dist/chunk-6QTCGJWX.js.map +0 -1
  58. package/dist/chunk-DFYZVBII.js +0 -652
  59. package/dist/chunk-DFYZVBII.js.map +0 -1
  60. package/dist/chunk-V647VNMY.js +0 -135
  61. package/dist/chunk-V647VNMY.js.map +0 -1
  62. /package/dist/{chunk-EYXBYV2X.js.map → chunk-GPHWC533.js.map} +0 -0
@@ -33,23 +33,52 @@ __export(typed_attributes_exports, {
33
33
  module.exports = __toCommonJS(typed_attributes_exports);
34
34
 
35
35
  // src/model/relational.ts
36
+ var LIKE_ESCAPE = "!";
37
+ function escapeLike(value) {
38
+ return value.replaceAll(LIKE_ESCAPE, LIKE_ESCAPE + LIKE_ESCAPE).replaceAll("%", LIKE_ESCAPE + "%").replaceAll("_", LIKE_ESCAPE + "_");
39
+ }
36
40
  var RelationalOperationElement = class {
37
41
  };
38
42
  var Operation = class extends RelationalOperationElement {
39
- andOp(other) {
43
+ /** Name this column in the result: `f.price().sum().alias('Total')`, `f.age().gt(30).alias('Adult')`. */
44
+ alias(name) {
45
+ return new Alias(this, name);
46
+ }
47
+ and(other) {
40
48
  return new LogicalOperation(this, "AND" /* AND */, other);
41
49
  }
50
+ /** Combine with `other` using OR. A chain reads left to right: `a.or(b).and(c)` is `(a OR b) AND c`. */
51
+ or(other) {
52
+ return new LogicalOperation(this, "OR" /* OR */, other);
53
+ }
42
54
  };
43
55
  var ConstantOperation = class extends RelationalOperationElement {
56
+ /** Name this column in the result. */
57
+ alias(name) {
58
+ return new Alias(this, name);
59
+ }
60
+ /** Sort by this expression, smallest first. */
61
+ ascending() {
62
+ return new SortOperation(this, "ASC" /* ASC */);
63
+ }
64
+ /** Sort by this expression, largest first. */
65
+ descending() {
66
+ return new SortOperation(this, "DESC" /* DESC */);
67
+ }
44
68
  };
45
- var IntegerConstantOperation = class extends ConstantOperation {
69
+ var NumericConstantOperation = class extends ConstantOperation {
70
+ arithmeticOperand() {
71
+ return this;
72
+ }
73
+ };
74
+ var IntegerConstantOperation = class extends NumericConstantOperation {
46
75
  constructor(value) {
47
76
  super();
48
77
  this.value = value;
49
78
  }
50
79
  value;
51
80
  };
52
- var FloatConstantOperation = class extends ConstantOperation {
81
+ var FloatConstantOperation = class extends NumericConstantOperation {
53
82
  constructor(value) {
54
83
  super();
55
84
  this.value = value;
@@ -63,6 +92,9 @@ var StringConstantOperation = class extends ConstantOperation {
63
92
  }
64
93
  value;
65
94
  };
95
+ var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
96
+ var DateOnly = class extends Date {
97
+ };
66
98
  var DateConstantOperation = class extends ConstantOperation {
67
99
  constructor(value) {
68
100
  super();
@@ -77,7 +109,7 @@ var DateTimeConstantOperation = class extends ConstantOperation {
77
109
  }
78
110
  value;
79
111
  };
80
- var DecimalConstantOperation = class extends ConstantOperation {
112
+ var DecimalConstantOperation = class extends NumericConstantOperation {
81
113
  constructor(value) {
82
114
  super();
83
115
  this.value = value;
@@ -111,6 +143,20 @@ var IsNullOperation = class extends UnaryOperation {
111
143
  };
112
144
  var IsNotNullOperation = class extends UnaryOperation {
113
145
  };
146
+ var InOperation = class extends UnaryOperation {
147
+ constructor(element, values) {
148
+ super(element);
149
+ this.values = values;
150
+ }
151
+ values;
152
+ };
153
+ var NotInOperation = class extends UnaryOperation {
154
+ constructor(element, values) {
155
+ super(element);
156
+ this.values = values;
157
+ }
158
+ values;
159
+ };
114
160
  var ComparisonOperation = class extends BinaryOperation {
115
161
  constructor(left, operator, right) {
116
162
  super(left, right);
@@ -134,21 +180,41 @@ var WindowSpecification = class {
134
180
  orderBy;
135
181
  };
136
182
  var AggregateOperation = class _AggregateOperation extends UnaryOperation {
137
- constructor(element, operator, displayName, window) {
183
+ constructor(element, operator, displayName, window, separator, orderBy = []) {
138
184
  super(element);
139
185
  this.operator = operator;
140
186
  this.displayName = displayName;
141
187
  this.window = window;
188
+ this.separator = separator;
189
+ this.orderBy = orderBy;
142
190
  }
143
191
  operator;
144
192
  displayName;
145
193
  window;
194
+ separator;
195
+ orderBy;
196
+ /** Sort by this expression, smallest first. */
197
+ ascending() {
198
+ return new SortOperation(this, "ASC" /* ASC */);
199
+ }
200
+ /** Sort by this expression, largest first. */
201
+ descending() {
202
+ return new SortOperation(this, "DESC" /* DESC */);
203
+ }
204
+ arithmeticOperand() {
205
+ return this;
206
+ }
207
+ comparisonOperand() {
208
+ return this;
209
+ }
146
210
  over(partitionBy, orderBy) {
147
211
  return new _AggregateOperation(
148
212
  this.element,
149
213
  this.operator,
150
214
  this.displayName,
151
- new WindowSpecification(partitionBy ?? [], orderBy ?? [])
215
+ new WindowSpecification(partitionBy ?? [], orderBy ?? []),
216
+ this.separator,
217
+ this.orderBy
152
218
  );
153
219
  }
154
220
  };
@@ -166,6 +232,14 @@ var WindowFunctionOperation = class _WindowFunctionOperation extends UnaryOperat
166
232
  secondArg;
167
233
  extraArgs;
168
234
  window;
235
+ /** Sort by this expression, smallest first. */
236
+ ascending() {
237
+ return new SortOperation(this, "ASC" /* ASC */);
238
+ }
239
+ /** Sort by this expression, largest first. */
240
+ descending() {
241
+ return new SortOperation(this, "DESC" /* DESC */);
242
+ }
169
243
  over(partitionBy, orderBy) {
170
244
  return new _WindowFunctionOperation(
171
245
  this.element,
@@ -189,7 +263,38 @@ var ScalarFunctionOperation = class extends UnaryOperation {
189
263
  displayName;
190
264
  secondArg;
191
265
  extraArgs;
266
+ /** Sort by this expression, smallest first. */
267
+ ascending() {
268
+ return new SortOperation(this, "ASC" /* ASC */);
269
+ }
270
+ /** Sort by this expression, largest first. */
271
+ descending() {
272
+ return new SortOperation(this, "DESC" /* DESC */);
273
+ }
274
+ /** This expression as an operand of a comparison. */
275
+ comparisonOperand() {
276
+ return this;
277
+ }
278
+ arithmeticOperand() {
279
+ return this;
280
+ }
281
+ /** Only a function that gives a number can be used in arithmetic. */
282
+ assertNumeric() {
283
+ if (!NUMERIC_FUNCTIONS.has(this.func)) {
284
+ throw new TypeError(`${this.func} does not give a number, so it cannot be used in arithmetic`);
285
+ }
286
+ }
192
287
  };
288
+ var NUMERIC_FUNCTIONS = /* @__PURE__ */ new Set([
289
+ "ABS" /* ABS */,
290
+ "CEILING" /* CEILING */,
291
+ "FLOOR" /* FLOOR */,
292
+ "MOD" /* MOD */,
293
+ "POWER" /* POWER */,
294
+ "SQRT" /* SQRT */,
295
+ "ROUND" /* ROUND */,
296
+ "LENGTH" /* LENGTH */
297
+ ]);
193
298
  var DateExtractOperation = class extends UnaryOperation {
194
299
  constructor(element, part, displayName) {
195
300
  super(element);
@@ -198,6 +303,34 @@ var DateExtractOperation = class extends UnaryOperation {
198
303
  }
199
304
  part;
200
305
  displayName;
306
+ /** Sort by this expression, smallest first. */
307
+ ascending() {
308
+ return new SortOperation(this, "ASC" /* ASC */);
309
+ }
310
+ /** Sort by this expression, largest first. */
311
+ descending() {
312
+ return new SortOperation(this, "DESC" /* DESC */);
313
+ }
314
+ };
315
+ var DateTruncOperation = class extends UnaryOperation {
316
+ constructor(element, part, displayName) {
317
+ super(element);
318
+ this.part = part;
319
+ this.displayName = displayName;
320
+ }
321
+ part;
322
+ displayName;
323
+ /** Sort by this expression, earliest first. */
324
+ ascending() {
325
+ return new SortOperation(this, "ASC" /* ASC */);
326
+ }
327
+ /** Sort by this expression, latest first. */
328
+ descending() {
329
+ return new SortOperation(this, "DESC" /* DESC */);
330
+ }
331
+ comparisonOperand() {
332
+ return this;
333
+ }
201
334
  };
202
335
  var DateArithmeticOperation = class extends UnaryOperation {
203
336
  constructor(element, n, unit, isAdd = true, displayName) {
@@ -211,6 +344,14 @@ var DateArithmeticOperation = class extends UnaryOperation {
211
344
  unit;
212
345
  isAdd;
213
346
  displayName;
347
+ /** Sort by this expression, smallest first. */
348
+ ascending() {
349
+ return new SortOperation(this, "ASC" /* ASC */);
350
+ }
351
+ /** Sort by this expression, largest first. */
352
+ descending() {
353
+ return new SortOperation(this, "DESC" /* DESC */);
354
+ }
214
355
  };
215
356
  var DateDiffOperation = class extends UnaryOperation {
216
357
  constructor(element, other, unit, displayName) {
@@ -222,29 +363,55 @@ var DateDiffOperation = class extends UnaryOperation {
222
363
  other;
223
364
  unit;
224
365
  displayName;
366
+ /** Sort by this expression, smallest first. */
367
+ ascending() {
368
+ return new SortOperation(this, "ASC" /* ASC */);
369
+ }
370
+ /** Sort by this expression, largest first. */
371
+ descending() {
372
+ return new SortOperation(this, "DESC" /* DESC */);
373
+ }
225
374
  };
226
375
  var Column = class extends RelationalOperationElement {
227
- constructor(name, type, owner, primaryKey = false) {
376
+ constructor(name, type, owner, primaryKey = false, nullable = true) {
228
377
  super();
229
378
  this.name = name;
230
379
  this.type = type;
231
380
  this.owner = owner;
232
381
  this.primaryKey = primaryKey;
382
+ this.nullable = nullable && !primaryKey;
233
383
  }
234
384
  name;
235
385
  type;
236
386
  owner;
237
387
  primaryKey;
238
388
  table;
389
+ /** Whether the column may hold NULL. As in Legend, a primary key is never null. */
390
+ nullable;
239
391
  };
240
392
  var ColumnWithJoin = class extends RelationalOperationElement {
241
- constructor(column, parent) {
393
+ /**
394
+ * `embedded` is an alternate reference to a flat (denormalized) column on the owning table that
395
+ * holds the same value without the join; the SQL generator uses it when the join can be elided.
396
+ */
397
+ constructor(column, parent, embedded, _optional = false) {
242
398
  super();
243
399
  this.column = column;
244
400
  this.parent = parent;
401
+ this.embedded = embedded;
402
+ this._optional = _optional;
245
403
  }
246
404
  column;
247
405
  parent;
406
+ embedded;
407
+ _optional;
408
+ /** Whether the value can be missing: its property is optional, or a navigation on the way to it is. */
409
+ get optional() {
410
+ for (let node = this.parent; node !== void 0; node = node.parent) {
411
+ if (node.optional) return true;
412
+ }
413
+ return this._optional;
414
+ }
248
415
  };
249
416
  var SortOperation = class {
250
417
  constructor(column, direction) {
@@ -254,18 +421,302 @@ var SortOperation = class {
254
421
  column;
255
422
  direction;
256
423
  };
424
+ var CountAllOperation = class extends RelationalOperationElement {
425
+ constructor(table) {
426
+ super();
427
+ this.table = table;
428
+ }
429
+ table;
430
+ /** Name this column in the result. */
431
+ alias(name) {
432
+ return new Alias(this, name);
433
+ }
434
+ /** Sort by this expression, smallest first. */
435
+ ascending() {
436
+ return new SortOperation(this, "ASC" /* ASC */);
437
+ }
438
+ /** Sort by this expression, largest first. */
439
+ descending() {
440
+ return new SortOperation(this, "DESC" /* DESC */);
441
+ }
442
+ comparisonOperand() {
443
+ return this;
444
+ }
445
+ };
446
+ var Alias = class _Alias extends RelationalOperationElement {
447
+ constructor(element, name) {
448
+ super();
449
+ this.element = element;
450
+ this.name = name;
451
+ }
452
+ element;
453
+ name;
454
+ alias(name) {
455
+ return new _Alias(this.element, name);
456
+ }
457
+ /** Sorts by the column the alias names. */
458
+ ascending() {
459
+ return new SortOperation(this.element, "ASC" /* ASC */);
460
+ }
461
+ /** Sorts by the column the alias names. */
462
+ descending() {
463
+ return new SortOperation(this.element, "DESC" /* DESC */);
464
+ }
465
+ };
466
+ var CaseOperation = class extends Operation {
467
+ constructor(condition, then, fallback, displayName) {
468
+ super();
469
+ this.condition = condition;
470
+ this.then = then;
471
+ this.fallback = fallback;
472
+ this.displayName = displayName;
473
+ }
474
+ condition;
475
+ then;
476
+ fallback;
477
+ displayName;
478
+ };
479
+ function valueOperand(value) {
480
+ if (typeof value === "boolean") return new BooleanConstantOperation(value);
481
+ if (typeof value === "number" && Number.isFinite(value)) {
482
+ return Number.isInteger(value) ? new IntegerConstantOperation(value) : new FloatConstantOperation(value);
483
+ }
484
+ if (typeof value === "string") return new StringConstantOperation(value);
485
+ if (value instanceof DateOnly) return new DateConstantOperation(value);
486
+ if (value instanceof Date) return new DateTimeConstantOperation(value);
487
+ throw new TypeError(`A value to compare with is a boolean, a finite number, a string or a date, not ${value === null ? "null" : typeof value}`);
488
+ }
489
+ function operandOf(other) {
490
+ if (other instanceof RelationalOperationElement) return other;
491
+ if (typeof other?.cwj === "function") return other.cwj();
492
+ return valueOperand(other);
493
+ }
494
+ var Comparable = class {
495
+ _compared(operator, other) {
496
+ return new ComparisonOperation(this.comparisonOperand(), operator, operandOf(other));
497
+ }
498
+ /** Filter to rows where this expression equals `other`. */
499
+ eq(other) {
500
+ return this._compared("EQUAL" /* EQUAL */, other);
501
+ }
502
+ /** Filter to rows where this expression does not equal `other`. */
503
+ ne(other) {
504
+ return this._compared("NOT_EQUAL" /* NOT_EQUAL */, other);
505
+ }
506
+ /** Filter to rows where this expression is less than `other`. */
507
+ lt(other) {
508
+ return this._compared("LESS_THAN" /* LESS_THAN */, other);
509
+ }
510
+ /** Filter to rows where this expression is at most `other`. */
511
+ lte(other) {
512
+ return this._compared("LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, other);
513
+ }
514
+ /** Filter to rows where this expression is greater than `other`. */
515
+ gt(other) {
516
+ return this._compared("GREATER_THAN" /* GREATER_THAN */, other);
517
+ }
518
+ /** Filter to rows where this expression is at least `other`. */
519
+ gte(other) {
520
+ return this._compared("GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, other);
521
+ }
522
+ };
523
+ function sample(ddof) {
524
+ if (ddof !== 0 && ddof !== 1) throw new RangeError(`ddof is 0 (population) or 1 (sample), not ${ddof}`);
525
+ return ddof === 1;
526
+ }
527
+ var StringPredicates = class {
528
+ _like(pattern) {
529
+ return new ComparisonOperation(this.comparisonOperand(), "LIKE" /* LIKE */, new StringConstantOperation(pattern));
530
+ }
531
+ /** Filter to rows where this text contains `value`. */
532
+ contains(value) {
533
+ return this._like(`%${escapeLike(value)}%`);
534
+ }
535
+ /** Filter to rows where this text starts with `prefix`. */
536
+ startsWith(prefix) {
537
+ return this._like(`${escapeLike(prefix)}%`);
538
+ }
539
+ /** Filter to rows where this text ends with `suffix`. */
540
+ endsWith(suffix) {
541
+ return this._like(`%${escapeLike(suffix)}`);
542
+ }
543
+ };
544
+ var Aggregates = class {
545
+ _aggregate(operator, label) {
546
+ return new AggregateOperation(this, operator, label + " Expression");
547
+ }
548
+ /** Sum of the values in the group. */
549
+ sum() {
550
+ return this._aggregate("SUM" /* SUM */, "Sum");
551
+ }
552
+ /** Smallest value in the group. */
553
+ min() {
554
+ return this._aggregate("MIN" /* MIN */, "Min");
555
+ }
556
+ /** Largest value in the group. */
557
+ max() {
558
+ return this._aggregate("MAX" /* MAX */, "Max");
559
+ }
560
+ /** Arithmetic mean of the values in the group. */
561
+ average() {
562
+ return this._aggregate("AVERAGE" /* AVERAGE */, "Average");
563
+ }
564
+ /** Number of non-null values in the group. */
565
+ count() {
566
+ return this._aggregate("COUNT" /* COUNT */, "Count");
567
+ }
568
+ /** Standard deviation of the values in the group: the sample one by default, `ddof = 0` for the population one. */
569
+ std(ddof = 1) {
570
+ return this._aggregate(sample(ddof) ? "STDDEV_SAMP" /* STDDEV_SAMP */ : "STDDEV_POP" /* STDDEV_POP */, "Std");
571
+ }
572
+ /** Variance of the values in the group: the sample one by default, `ddof = 0` for the population one. */
573
+ var(ddof = 1) {
574
+ return this._aggregate(sample(ddof) ? "VAR_SAMP" /* VAR_SAMP */ : "VAR_POP" /* VAR_POP */, "Var");
575
+ }
576
+ };
577
+ var BooleanAggregates = class {
578
+ /** True for a group where every row satisfies the condition. */
579
+ all() {
580
+ return new AggregateOperation(this, "BOOL_AND" /* BOOL_AND */, "All Expression");
581
+ }
582
+ /** True for a group where at least one row satisfies the condition. */
583
+ any() {
584
+ return new AggregateOperation(this, "BOOL_OR" /* BOOL_OR */, "Any Expression");
585
+ }
586
+ };
587
+ function applyMixins(derived, bases) {
588
+ for (const base of bases) {
589
+ for (const name of Object.getOwnPropertyNames(base.prototype)) {
590
+ if (name === "constructor" || Object.prototype.hasOwnProperty.call(derived.prototype, name)) continue;
591
+ Object.defineProperty(derived.prototype, name, Object.getOwnPropertyDescriptor(base.prototype, name));
592
+ }
593
+ }
594
+ }
595
+ var Arithmetic = class {
596
+ /** Raises if this expression is not a number. */
597
+ assertNumeric() {
598
+ }
599
+ _arithmetic(operator, other) {
600
+ this.assertNumeric();
601
+ let operand;
602
+ if (typeof other === "number") {
603
+ if (!Number.isFinite(other)) throw new TypeError("Arithmetic is between numbers and numeric columns, not a non-finite number");
604
+ operand = valueOperand(other);
605
+ } else if (other !== null && typeof other === "object" && typeof other.arithmeticOperand === "function") {
606
+ other.assertNumeric?.();
607
+ operand = other.arithmeticOperand();
608
+ } else {
609
+ throw new TypeError(`Arithmetic is between numbers and numeric columns, not ${other === null ? "null" : typeof other}`);
610
+ }
611
+ return new ArithmeticOperation(this.arithmeticOperand(), operator, operand);
612
+ }
613
+ /** `this + other`. */
614
+ plus(other) {
615
+ return this._arithmetic("+" /* ADD */, other);
616
+ }
617
+ /** `this - other`. */
618
+ minus(other) {
619
+ return this._arithmetic("-" /* SUBTRACT */, other);
620
+ }
621
+ /** `this * other`. */
622
+ times(other) {
623
+ return this._arithmetic("*" /* MULTIPLY */, other);
624
+ }
625
+ /** `this / other`. */
626
+ dividedBy(other) {
627
+ return this._arithmetic("/" /* DIVIDE */, other);
628
+ }
629
+ };
630
+ var ArithmeticOperation = class extends BinaryOperation {
631
+ constructor(left, operator, right, displayName) {
632
+ super(left, right);
633
+ this.operator = operator;
634
+ this.displayName = displayName;
635
+ }
636
+ operator;
637
+ displayName;
638
+ /** Sort by this expression, smallest first. */
639
+ ascending() {
640
+ return new SortOperation(this, "ASC" /* ASC */);
641
+ }
642
+ /** Sort by this expression, largest first. */
643
+ descending() {
644
+ return new SortOperation(this, "DESC" /* DESC */);
645
+ }
646
+ arithmeticOperand() {
647
+ return this;
648
+ }
649
+ comparisonOperand() {
650
+ return this;
651
+ }
652
+ };
653
+ var ConcatOperation = class extends Operation {
654
+ constructor(parts, displayName) {
655
+ super();
656
+ this.parts = parts;
657
+ this.displayName = displayName;
658
+ }
659
+ parts;
660
+ displayName;
661
+ /** Join more text on the end: `f.first().concat(' ', f.last())`. A concatenation joins into one. */
662
+ concat(...more) {
663
+ return concat(this, ...more);
664
+ }
665
+ /** Sort by this expression, smallest first. */
666
+ ascending() {
667
+ return new SortOperation(this, "ASC" /* ASC */);
668
+ }
669
+ /** Sort by this expression, largest first. */
670
+ descending() {
671
+ return new SortOperation(this, "DESC" /* DESC */);
672
+ }
673
+ comparisonOperand() {
674
+ return this;
675
+ }
676
+ };
677
+ function concat(...parts) {
678
+ const partsOf = (part) => {
679
+ if (part instanceof ConcatOperation) return part.parts;
680
+ if (typeof part === "string") return [new StringConstantOperation(part)];
681
+ if (part instanceof RelationalOperationElement) return [part];
682
+ if (part !== null && typeof part === "object" && typeof part.functionInput === "function") return [part.functionInput()];
683
+ throw new TypeError(`Text is joined with text, not ${part === null ? "null" : typeof part}`);
684
+ };
685
+ return new ConcatOperation(parts.flatMap(partsOf));
686
+ }
687
+ applyMixins(ConcatOperation, [Comparable, StringPredicates]);
688
+ applyMixins(DateTruncOperation, [Comparable]);
689
+ applyMixins(ArithmeticOperation, [Arithmetic, Comparable]);
690
+ applyMixins(ScalarFunctionOperation, [Comparable, Arithmetic, StringPredicates]);
691
+ applyMixins(AggregateOperation, [Arithmetic, Comparable, StringPredicates]);
692
+ applyMixins(CountAllOperation, [Comparable]);
693
+ applyMixins(NumericConstantOperation, [Arithmetic]);
694
+ applyMixins(ConstantOperation, [Aggregates]);
695
+ applyMixins(ArithmeticOperation, [Aggregates]);
696
+ applyMixins(ScalarFunctionOperation, [Aggregates]);
697
+ applyMixins(CaseOperation, [Aggregates]);
698
+ applyMixins(IsNullOperation, [BooleanAggregates]);
699
+ applyMixins(IsNotNullOperation, [BooleanAggregates]);
700
+ applyMixins(InOperation, [BooleanAggregates]);
701
+ applyMixins(NotInOperation, [BooleanAggregates]);
702
+ applyMixins(ComparisonOperation, [BooleanAggregates]);
703
+ applyMixins(LogicalOperation, [BooleanAggregates]);
257
704
 
258
705
  // src/datafinder/attribute.ts
259
- var Attribute = class {
706
+ var Attribute = class _Attribute {
260
707
  _displayName;
261
708
  _column;
262
709
  _owner;
263
710
  _parent;
264
- constructor(displayName, columnName, columnDbType, owner, parent) {
711
+ _embedded;
712
+ _optional;
713
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded, nullable = true, optional = false) {
714
+ this._optional = optional;
265
715
  this._displayName = displayName;
266
- this._column = new Column(columnName, columnDbType, owner);
716
+ this._column = new Column(columnName, columnDbType, owner, false, nullable);
267
717
  this._owner = owner;
268
718
  this._parent = parent;
719
+ this._embedded = embedded;
269
720
  }
270
721
  column() {
271
722
  return this._column;
@@ -279,33 +730,102 @@ var Attribute = class {
279
730
  displayName() {
280
731
  return this._displayName;
281
732
  }
733
+ /** Alternate attribute on a flat column of the owning table, used in place of this one when its join is elided. */
734
+ embedded() {
735
+ return this._embedded;
736
+ }
737
+ /** @internal The expression a function of this attribute applies to: its column. */
738
+ functionInput() {
739
+ return this.cwj();
740
+ }
741
+ /** @internal What a function of this attribute is labelled after: its display name. */
742
+ functionLabel() {
743
+ return this._displayName;
744
+ }
745
+ /** @internal This attribute as an operand of arithmetic: its column. */
746
+ arithmeticOperand() {
747
+ return this.cwj();
748
+ }
282
749
  cwj() {
283
- return new ColumnWithJoin(this._column, this._parent);
750
+ return new ColumnWithJoin(this._column, this._parent, this._embedded?.cwj(), this._optional);
284
751
  }
752
+ /** Count the number of non-null values. Use in a projection with `groupBy` to aggregate per group. */
285
753
  count() {
286
754
  return new AggregateOperation(
287
- new ColumnWithJoin(this._column, this._parent),
755
+ this.cwj(),
288
756
  "COUNT" /* COUNT */,
289
757
  this._displayName + " Count"
290
758
  );
291
759
  }
760
+ /** Name this column in the result: `f.price().sum().alias('Total')`. */
761
+ alias(name) {
762
+ return new Alias(this, name);
763
+ }
764
+ /** The number of different non-NULL values in the group: `COUNT(DISTINCT column)`. Use with `groupBy` to count per group. */
765
+ countDistinct() {
766
+ return new AggregateOperation(this.cwj(), "COUNT_DISTINCT" /* COUNT_DISTINCT */, this._displayName + " Count Distinct");
767
+ }
768
+ /** The value, or `defaultValue` when it is NULL: `name().orElse('N/A')`. Like `COALESCE` in SQL. */
769
+ orElse(defaultValue) {
770
+ if (!["string", "number", "boolean"].includes(typeof defaultValue)) {
771
+ throw new TypeError(`An orElse default is a string, number or boolean, not ${defaultValue === null ? "null" : typeof defaultValue}`);
772
+ }
773
+ return new ScalarFunctionOperation(this.cwj(), "COALESCE" /* COALESCE */, "Or Else " + this._displayName, void 0, [defaultValue]);
774
+ }
775
+ /** Sort this attribute in ascending order. Pass to `orderBy` or a window function's `orderBy`. */
292
776
  ascending() {
293
- return new SortOperation(new ColumnWithJoin(this._column, this._parent), "ASC" /* ASC */);
777
+ return new SortOperation(this.cwj(), "ASC" /* ASC */);
294
778
  }
779
+ /** Sort this attribute in descending order. Pass to `orderBy` or a window function's `orderBy`. */
295
780
  descending() {
296
- return new SortOperation(new ColumnWithJoin(this._column, this._parent), "DESC" /* DESC */);
781
+ return new SortOperation(this.cwj(), "DESC" /* DESC */);
297
782
  }
783
+ /** Filter to rows where this attribute has no value. */
298
784
  isNull() {
299
- return new IsNullOperation(new ColumnWithJoin(this._column, this._parent));
785
+ return new IsNullOperation(this.cwj());
300
786
  }
787
+ /** Filter to rows where this attribute has a value. */
301
788
  isNotNull() {
302
- return new IsNotNullOperation(new ColumnWithJoin(this._column, this._parent));
789
+ return new IsNotNullOperation(this.cwj());
790
+ }
791
+ /** Wrap a value as a constant of this attribute's type. Overridden by the typed attributes. */
792
+ toConstant(_value) {
793
+ throw new TypeError(`${this.constructor.name} does not support isIn / isNotIn`);
794
+ }
795
+ _constants(values) {
796
+ const constants = values.map((v) => this.toConstant(v));
797
+ if (constants.length === 0) throw new Error("isIn / isNotIn need at least one value");
798
+ return constants;
799
+ }
800
+ /** Filter to rows where this attribute equals any of `values`. */
801
+ isIn(values) {
802
+ return new InOperation(this.cwj(), this._constants(values));
803
+ }
804
+ /** Filter to rows where this attribute equals none of `values`. Rows with no value are excluded, as in SQL. */
805
+ isNotIn(values) {
806
+ return new NotInOperation(this.cwj(), this._constants(values));
303
807
  }
304
808
  _windowSpec(partitionBy, orderBy) {
305
- const pb = partitionBy === void 0 ? [] : Array.isArray(partitionBy) ? partitionBy : [partitionBy];
809
+ const pbArr = partitionBy === void 0 ? [] : Array.isArray(partitionBy) ? partitionBy : [partitionBy];
810
+ const pb = pbArr.map((x) => x instanceof _Attribute ? x.cwj() : x);
306
811
  const ob = orderBy === void 0 ? [] : Array.isArray(orderBy) ? orderBy : [orderBy];
307
812
  return new WindowSpecification(pb, ob);
308
813
  }
814
+ /**
815
+ * Assign a rank to each row within the ordered window, following pandas `Series.rank` conventions.
816
+ *
817
+ * `method` controls tie-breaking (default `'min'`):
818
+ * - `'min'` — tied rows share the lowest rank; the next rank skips.
819
+ * - `'dense'` — like `'min'` but ranks are contiguous (no gaps).
820
+ * - `'first'` — each row gets a unique sequential integer (no ties).
821
+ * - `'max'` — only meaningful with `pct: true` (see below).
822
+ *
823
+ * When `pct: true` the result is a relative rank between 0 and 1:
824
+ * - `method: 'min'` (default) → fraction of values strictly below this row (PERCENT_RANK).
825
+ * - `method: 'max'` → fraction of values at or below this row (cumulative distribution).
826
+ *
827
+ * `partitionBy` restarts the ranking within each group of distinct values.
828
+ */
309
829
  rank(opts = {}) {
310
830
  const { method = "min", pct = false, partitionBy, orderBy } = opts;
311
831
  let func;
@@ -330,6 +850,11 @@ var Attribute = class {
330
850
  }
331
851
  return new WindowFunctionOperation(null, func, name, void 0, [], this._windowSpec(partitionBy, orderBy));
332
852
  }
853
+ /**
854
+ * Split rows into `buckets` equal-sized quantile bins ordered by `orderBy`.
855
+ * Each row receives a bucket number from 1 (lowest) to `buckets` (highest).
856
+ * Named after `pandas.qcut`.
857
+ */
333
858
  qcut(buckets, opts = {}) {
334
859
  return new WindowFunctionOperation(
335
860
  null,
@@ -340,12 +865,17 @@ var Attribute = class {
340
865
  this._windowSpec(opts.partitionBy, opts.orderBy)
341
866
  );
342
867
  }
868
+ /**
869
+ * Return the value of this attribute from `periods` rows earlier (positive) or later (negative)
870
+ * within the ordered window, following `pandas.Series.shift`.
871
+ * Rows with no neighbour at the given offset return `null` (or `fillValue` if provided).
872
+ */
343
873
  shift(periods = 1, opts = {}) {
344
874
  const extraArgs = opts.fillValue !== void 0 ? [opts.fillValue] : [];
345
875
  const func = periods >= 0 ? "LAG" /* LAG */ : "LEAD" /* LEAD */;
346
876
  const label = periods >= 0 ? "Lag" : "Lead";
347
877
  return new WindowFunctionOperation(
348
- new ColumnWithJoin(this._column, this._parent),
878
+ this.cwj(),
349
879
  func,
350
880
  label + " " + this._displayName,
351
881
  Math.abs(periods),
@@ -353,9 +883,13 @@ var Attribute = class {
353
883
  this._windowSpec(opts.partitionBy, opts.orderBy)
354
884
  );
355
885
  }
886
+ /**
887
+ * Return the first value of this attribute in the window frame.
888
+ * Use `partitionBy` to restart the frame for each group.
889
+ */
356
890
  first(opts = {}) {
357
891
  return new WindowFunctionOperation(
358
- new ColumnWithJoin(this._column, this._parent),
892
+ this.cwj(),
359
893
  "FIRST_VALUE" /* FIRST_VALUE */,
360
894
  "First " + this._displayName,
361
895
  void 0,
@@ -363,9 +897,13 @@ var Attribute = class {
363
897
  this._windowSpec(opts.partitionBy, opts.orderBy)
364
898
  );
365
899
  }
900
+ /**
901
+ * Return the last value of this attribute in the window frame.
902
+ * Use `partitionBy` to restart the frame for each group.
903
+ */
366
904
  last(opts = {}) {
367
905
  return new WindowFunctionOperation(
368
- new ColumnWithJoin(this._column, this._parent),
906
+ this.cwj(),
369
907
  "LAST_VALUE" /* LAST_VALUE */,
370
908
  "Last " + this._displayName,
371
909
  void 0,
@@ -375,185 +913,311 @@ var Attribute = class {
375
913
  }
376
914
  };
377
915
 
378
- // src/datafinder/typed-attributes.ts
379
- var StringAttribute = class extends Attribute {
380
- constructor(displayName, columnName, columnDbType, owner, parent) {
381
- super(displayName, columnName, columnDbType, owner, parent);
916
+ // src/datafinder/scalar-functions.ts
917
+ var StringFunctionOperation = class extends ScalarFunctionOperation {
918
+ functionInput() {
919
+ return this;
920
+ }
921
+ functionLabel() {
922
+ return labelOf(this);
382
923
  }
383
- upper() {
384
- return new ScalarFunctionOperation(this.cwj(), "UPPER" /* UPPER */, "Upper " + this.displayName());
924
+ };
925
+ var NumericFunctionOperation = class extends ScalarFunctionOperation {
926
+ functionInput() {
927
+ return this;
385
928
  }
386
- lower() {
387
- return new ScalarFunctionOperation(this.cwj(), "LOWER" /* LOWER */, "Lower " + this.displayName());
929
+ functionLabel() {
930
+ return labelOf(this);
388
931
  }
389
- strip() {
390
- return new ScalarFunctionOperation(this.cwj(), "TRIM" /* TRIM */, "Strip " + this.displayName());
932
+ };
933
+ function labelOf(operation) {
934
+ return operation.displayName ?? operation.func.charAt(0) + operation.func.slice(1).toLowerCase();
935
+ }
936
+ function stringFunction(element, func, label, secondArg, extraArgs = []) {
937
+ return new StringFunctionOperation(element, func, label, secondArg, extraArgs);
938
+ }
939
+ function numberFunction(element, func, label, secondArg) {
940
+ return new NumericFunctionOperation(element, func, label, secondArg);
941
+ }
942
+ var StringFunctions = class {
943
+ /** Join text on the end: `f.first().concat(' ', f.last())`. A NULL part makes the whole NULL. */
944
+ concat(...more) {
945
+ return concat(this, ...more);
391
946
  }
392
- lstrip() {
393
- return new ScalarFunctionOperation(this.cwj(), "LTRIM" /* LTRIM */, "LStrip " + this.displayName());
947
+ /** Convert every character to uppercase. */
948
+ toUpperCase() {
949
+ return stringFunction(this.functionInput(), "UPPER" /* UPPER */, "Upper " + this.functionLabel());
394
950
  }
395
- rstrip() {
396
- return new ScalarFunctionOperation(this.cwj(), "RTRIM" /* RTRIM */, "RStrip " + this.displayName());
951
+ /** Convert every character to lowercase. */
952
+ toLowerCase() {
953
+ return stringFunction(this.functionInput(), "LOWER" /* LOWER */, "Lower " + this.functionLabel());
397
954
  }
955
+ /** Remove leading and trailing whitespace. */
956
+ trim() {
957
+ return stringFunction(this.functionInput(), "TRIM" /* TRIM */, "Trim " + this.functionLabel());
958
+ }
959
+ /** Remove leading whitespace. */
960
+ trimStart() {
961
+ return stringFunction(this.functionInput(), "LTRIM" /* LTRIM */, "Trim Start " + this.functionLabel());
962
+ }
963
+ /** Remove trailing whitespace. */
964
+ trimEnd() {
965
+ return stringFunction(this.functionInput(), "RTRIM" /* RTRIM */, "Trim End " + this.functionLabel());
966
+ }
967
+ /** Return the number of characters in the string. */
398
968
  length() {
399
- return new ScalarFunctionOperation(this.cwj(), "LENGTH" /* LENGTH */, "Length " + this.displayName());
969
+ return numberFunction(this.functionInput(), "LENGTH" /* LENGTH */, "Length " + this.functionLabel());
400
970
  }
971
+ /** Return the string with characters in reverse order. */
401
972
  reverse() {
402
- return new ScalarFunctionOperation(this.cwj(), "REVERSE" /* REVERSE */, "Reverse " + this.displayName());
973
+ return stringFunction(this.functionInput(), "REVERSE" /* REVERSE */, "Reverse " + this.functionLabel());
403
974
  }
975
+ /** Return the first `n` characters. */
404
976
  left(n) {
405
- return new ScalarFunctionOperation(this.cwj(), "LEFT" /* LEFT */, "Left " + this.displayName(), n);
977
+ return stringFunction(this.functionInput(), "LEFT" /* LEFT */, "Left " + this.functionLabel(), n);
406
978
  }
979
+ /** Return the last `n` characters. */
407
980
  right(n) {
408
- return new ScalarFunctionOperation(this.cwj(), "RIGHT" /* RIGHT */, "Right " + this.displayName(), n);
981
+ return stringFunction(this.functionInput(), "RIGHT" /* RIGHT */, "Right " + this.functionLabel(), n);
409
982
  }
983
+ /** Return the string repeated `n` times. */
410
984
  repeat(n) {
411
- return new ScalarFunctionOperation(this.cwj(), "REPEAT" /* REPEAT */, "Repeat " + this.displayName(), n);
985
+ return stringFunction(this.functionInput(), "REPEAT" /* REPEAT */, "Repeat " + this.functionLabel(), n);
412
986
  }
987
+ /** Replace all occurrences of `fromStr` with `toStr`. */
413
988
  replace(fromStr, toStr) {
414
- return new ScalarFunctionOperation(this.cwj(), "REPLACE" /* REPLACE */, "Replace " + this.displayName(), void 0, [fromStr, toStr]);
989
+ return stringFunction(this.functionInput(), "REPLACE" /* REPLACE */, "Replace " + this.functionLabel(), void 0, [fromStr, toStr]);
415
990
  }
991
+ /**
992
+ * Extract a portion of the string.
993
+ * `start` is zero-based (following Python convention); `length` is optional.
994
+ */
416
995
  substring(start, length) {
417
996
  const args = length !== void 0 ? [start + 1, length] : [start + 1];
418
- return new ScalarFunctionOperation(this.cwj(), "SUBSTRING" /* SUBSTRING */, "Substring " + this.displayName(), void 0, args);
997
+ return stringFunction(this.functionInput(), "SUBSTRING" /* SUBSTRING */, "Substring " + this.functionLabel(), void 0, args);
998
+ }
999
+ };
1000
+ var NumericFunctions = class {
1001
+ /** Absolute value (distance from zero, always non-negative). */
1002
+ abs() {
1003
+ return numberFunction(this.functionInput(), "ABS" /* ABS */, "Abs " + this.functionLabel());
1004
+ }
1005
+ /** Round up to the nearest integer. */
1006
+ ceil() {
1007
+ return numberFunction(this.functionInput(), "CEILING" /* CEILING */, "Ceil " + this.functionLabel());
1008
+ }
1009
+ /** Round down to the nearest integer. */
1010
+ floor() {
1011
+ return numberFunction(this.functionInput(), "FLOOR" /* FLOOR */, "Floor " + this.functionLabel());
1012
+ }
1013
+ /** Square root. */
1014
+ sqrt() {
1015
+ return numberFunction(this.functionInput(), "SQRT" /* SQRT */, "Sqrt " + this.functionLabel());
1016
+ }
1017
+ /** Remainder after dividing by `n`. */
1018
+ mod(n) {
1019
+ return numberFunction(this.functionInput(), "MOD" /* MOD */, "Mod " + this.functionLabel(), n);
1020
+ }
1021
+ /** Raise to the power of `n`. */
1022
+ power(n) {
1023
+ return numberFunction(this.functionInput(), "POWER" /* POWER */, "Power " + this.functionLabel(), n);
419
1024
  }
1025
+ /** Round to `d` decimal places, or to the nearest integer when `d` is omitted. */
1026
+ round(d) {
1027
+ return numberFunction(this.functionInput(), "ROUND" /* ROUND */, "Round " + this.functionLabel(), d);
1028
+ }
1029
+ };
1030
+ applyMixins(StringFunctionOperation, [StringFunctions]);
1031
+ applyMixins(NumericFunctionOperation, [NumericFunctions]);
1032
+
1033
+ // src/datafinder/typed-attributes.ts
1034
+ var MinMax = class {
1035
+ /** Smallest value in the group. */
1036
+ min() {
1037
+ return new AggregateOperation(this.cwj(), "MIN" /* MIN */, "Min " + this.displayName());
1038
+ }
1039
+ /** Largest value in the group. */
1040
+ max() {
1041
+ return new AggregateOperation(this.cwj(), "MAX" /* MAX */, "Max " + this.displayName());
1042
+ }
1043
+ };
1044
+ var StringAttribute = class extends Attribute {
1045
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded, nullable = true, optional = false) {
1046
+ super(displayName, columnName, columnDbType, owner, parent, embedded, nullable, optional);
1047
+ }
1048
+ toConstant(value) {
1049
+ return new StringConstantOperation(String(value));
1050
+ }
1051
+ /**
1052
+ * Join the values of a group into one text with `separator` between them. `orderBy` is the order they are
1053
+ * joined in (`[f.name().ascending()]`); without it the order is not defined. Missing values are skipped.
1054
+ */
1055
+ join(separator = "", orderBy = []) {
1056
+ return new AggregateOperation(this.cwj(), "STRING_AGG" /* STRING_AGG */, "Join " + this.displayName(), void 0, separator, orderBy);
1057
+ }
1058
+ /** Filter to rows where this attribute equals `value`. */
420
1059
  eq(value) {
421
1060
  return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new StringConstantOperation(value));
422
1061
  }
1062
+ /** Filter to rows where this attribute does not equal `value`. */
423
1063
  ne(value) {
424
1064
  return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new StringConstantOperation(value));
425
1065
  }
1066
+ /** Filter to rows where this attribute contains `value` as a substring. */
426
1067
  contains(value) {
427
- return new ComparisonOperation(this.cwj(), "LIKE" /* LIKE */, new StringConstantOperation(`%${value}%`));
1068
+ return new ComparisonOperation(this.cwj(), "LIKE" /* LIKE */, new StringConstantOperation(`%${escapeLike(value)}%`));
428
1069
  }
1070
+ /** Filter to rows where this attribute begins with `prefix`. */
429
1071
  startsWith(prefix) {
430
- return new ComparisonOperation(this.cwj(), "LIKE" /* LIKE */, new StringConstantOperation(`${prefix}%`));
1072
+ return new ComparisonOperation(this.cwj(), "LIKE" /* LIKE */, new StringConstantOperation(`${escapeLike(prefix)}%`));
431
1073
  }
1074
+ /** Filter to rows where this attribute ends with `suffix`. */
432
1075
  endsWith(suffix) {
433
- return new ComparisonOperation(this.cwj(), "LIKE" /* LIKE */, new StringConstantOperation(`%${suffix}`));
1076
+ return new ComparisonOperation(this.cwj(), "LIKE" /* LIKE */, new StringConstantOperation(`%${escapeLike(suffix)}`));
434
1077
  }
1078
+ /** Filter to rows where this attribute does not contain `value` as a substring. */
435
1079
  notContains(value) {
436
- return new ComparisonOperation(this.cwj(), "NOT_LIKE" /* NOT_LIKE */, new StringConstantOperation(`%${value}%`));
1080
+ return new ComparisonOperation(this.cwj(), "NOT_LIKE" /* NOT_LIKE */, new StringConstantOperation(`%${escapeLike(value)}%`));
437
1081
  }
438
1082
  };
1083
+ applyMixins(StringAttribute, [MinMax, StringFunctions]);
439
1084
  var NumericAttribute = class extends Attribute {
440
- constructor(displayName, columnName, columnDbType, owner, parent) {
441
- super(displayName, columnName, columnDbType, owner, parent);
1085
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded, nullable = true, optional = false) {
1086
+ super(displayName, columnName, columnDbType, owner, parent, embedded, nullable, optional);
442
1087
  }
1088
+ /** Sum of all values in the group. */
443
1089
  sum() {
444
- return new AggregateOperation(this.cwj(), "SUM" /* SUM */, this.displayName() + " Sum");
445
- }
446
- min() {
447
- return new AggregateOperation(this.cwj(), "MIN" /* MIN */, this.displayName() + " Min");
448
- }
449
- max() {
450
- return new AggregateOperation(this.cwj(), "MAX" /* MAX */, this.displayName() + " Max");
1090
+ return new AggregateOperation(this.cwj(), "SUM" /* SUM */, "Sum " + this.displayName());
451
1091
  }
1092
+ /** Arithmetic mean of all values in the group. */
452
1093
  average() {
453
- return new AggregateOperation(this.cwj(), "AVERAGE" /* AVERAGE */, this.displayName() + " Average");
454
- }
455
- abs() {
456
- return new ScalarFunctionOperation(this.cwj(), "ABS" /* ABS */, "Abs " + this.displayName());
457
- }
458
- ceil() {
459
- return new ScalarFunctionOperation(this.cwj(), "CEILING" /* CEILING */, "Ceil " + this.displayName());
1094
+ return new AggregateOperation(this.cwj(), "AVERAGE" /* AVERAGE */, "Average " + this.displayName());
460
1095
  }
461
- floor() {
462
- return new ScalarFunctionOperation(this.cwj(), "FLOOR" /* FLOOR */, "Floor " + this.displayName());
1096
+ /** Standard deviation of the values in the group: the sample one by default, `ddof = 0` for the population one, as `Series.std`. */
1097
+ std(ddof = 1) {
1098
+ const operator = sample(ddof) ? "STDDEV_SAMP" /* STDDEV_SAMP */ : "STDDEV_POP" /* STDDEV_POP */;
1099
+ return new AggregateOperation(this.cwj(), operator, "Std " + this.displayName());
463
1100
  }
464
- sqrt() {
465
- return new ScalarFunctionOperation(this.cwj(), "SQRT" /* SQRT */, "Sqrt " + this.displayName());
466
- }
467
- mod(n) {
468
- return new ScalarFunctionOperation(this.cwj(), "MOD" /* MOD */, "Mod " + this.displayName(), n);
469
- }
470
- power(n) {
471
- return new ScalarFunctionOperation(this.cwj(), "POWER" /* POWER */, "Power " + this.displayName(), n);
472
- }
473
- round(d) {
474
- return new ScalarFunctionOperation(this.cwj(), "ROUND" /* ROUND */, "Round " + this.displayName(), d);
1101
+ /** Variance of the values in the group: the sample one by default, `ddof = 0` for the population one, as `Series.var`. */
1102
+ var(ddof = 1) {
1103
+ const operator = sample(ddof) ? "VAR_SAMP" /* VAR_SAMP */ : "VAR_POP" /* VAR_POP */;
1104
+ return new AggregateOperation(this.cwj(), operator, "Var " + this.displayName());
475
1105
  }
476
1106
  };
1107
+ applyMixins(NumericAttribute, [MinMax, NumericFunctions, Arithmetic]);
477
1108
  var DoubleAttribute = class extends NumericAttribute {
478
- constructor(displayName, columnName, columnDbType, owner, parent) {
479
- super(displayName, columnName, columnDbType, owner, parent);
1109
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded, nullable = true, optional = false) {
1110
+ super(displayName, columnName, columnDbType, owner, parent, embedded, nullable, optional);
480
1111
  }
1112
+ toConstant(value) {
1113
+ return new FloatConstantOperation(Number(value));
1114
+ }
1115
+ /** Filter to rows where this attribute equals `value`. */
481
1116
  eq(value) {
482
1117
  return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new FloatConstantOperation(value));
483
1118
  }
1119
+ /** Filter to rows where this attribute does not equal `value`. */
484
1120
  ne(value) {
485
1121
  return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new FloatConstantOperation(value));
486
1122
  }
1123
+ /** Filter to rows where this attribute is greater than `value`. */
487
1124
  gt(value) {
488
1125
  return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, new FloatConstantOperation(value));
489
1126
  }
1127
+ /** Filter to rows where this attribute is less than `value`. */
490
1128
  lt(value) {
491
1129
  return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, new FloatConstantOperation(value));
492
1130
  }
1131
+ /** Filter to rows where this attribute is greater than or equal to `value`. */
493
1132
  gte(value) {
494
1133
  return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, new FloatConstantOperation(value));
495
1134
  }
1135
+ /** Filter to rows where this attribute is less than or equal to `value`. */
496
1136
  lte(value) {
497
1137
  return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, new FloatConstantOperation(value));
498
1138
  }
499
1139
  };
500
1140
  var FloatAttribute = DoubleAttribute;
501
1141
  var DecimalAttribute = class extends NumericAttribute {
502
- constructor(displayName, columnName, columnDbType, owner, parent) {
503
- super(displayName, columnName, columnDbType, owner, parent);
1142
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded, nullable = true, optional = false) {
1143
+ super(displayName, columnName, columnDbType, owner, parent, embedded, nullable, optional);
1144
+ }
1145
+ toConstant(value) {
1146
+ return new DecimalConstantOperation(Number(value));
504
1147
  }
1148
+ /** Filter to rows where this attribute equals `value`. */
505
1149
  eq(value) {
506
1150
  return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new DecimalConstantOperation(value));
507
1151
  }
1152
+ /** Filter to rows where this attribute does not equal `value`. */
508
1153
  ne(value) {
509
1154
  return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new DecimalConstantOperation(value));
510
1155
  }
1156
+ /** Filter to rows where this attribute is greater than `value`. */
511
1157
  gt(value) {
512
1158
  return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, new DecimalConstantOperation(value));
513
1159
  }
1160
+ /** Filter to rows where this attribute is less than `value`. */
514
1161
  lt(value) {
515
1162
  return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, new DecimalConstantOperation(value));
516
1163
  }
1164
+ /** Filter to rows where this attribute is greater than or equal to `value`. */
517
1165
  gte(value) {
518
1166
  return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, new DecimalConstantOperation(value));
519
1167
  }
1168
+ /** Filter to rows where this attribute is less than or equal to `value`. */
520
1169
  lte(value) {
521
1170
  return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, new DecimalConstantOperation(value));
522
1171
  }
523
1172
  };
524
1173
  var IntegerAttribute = class extends NumericAttribute {
525
- constructor(displayName, columnName, columnDbType, owner, parent) {
526
- super(displayName, columnName, columnDbType, owner, parent);
1174
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded, nullable = true, optional = false) {
1175
+ super(displayName, columnName, columnDbType, owner, parent, embedded, nullable, optional);
527
1176
  }
1177
+ toConstant(value) {
1178
+ return new IntegerConstantOperation(Number(value));
1179
+ }
1180
+ /** Filter to rows where this attribute equals `value`. */
528
1181
  eq(value) {
529
1182
  return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new IntegerConstantOperation(value));
530
1183
  }
1184
+ /** Filter to rows where this attribute does not equal `value`. */
531
1185
  ne(value) {
532
1186
  return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new IntegerConstantOperation(value));
533
1187
  }
1188
+ /** Filter to rows where this attribute is greater than `value`. */
534
1189
  gt(value) {
535
1190
  return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, new IntegerConstantOperation(value));
536
1191
  }
1192
+ /** Filter to rows where this attribute is less than `value`. */
537
1193
  lt(value) {
538
1194
  return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, new IntegerConstantOperation(value));
539
1195
  }
1196
+ /** Filter to rows where this attribute is greater than or equal to `value`. */
540
1197
  gte(value) {
541
1198
  return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, new IntegerConstantOperation(value));
542
1199
  }
1200
+ /** Filter to rows where this attribute is less than or equal to `value`. */
543
1201
  lte(value) {
544
1202
  return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, new IntegerConstantOperation(value));
545
1203
  }
546
1204
  };
547
1205
  var BooleanAttribute = class extends Attribute {
548
- constructor(displayName, columnName, columnDbType, owner, parent) {
549
- super(displayName, columnName, columnDbType, owner, parent);
1206
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded, nullable = true, optional = false) {
1207
+ super(displayName, columnName, columnDbType, owner, parent, embedded, nullable, optional);
1208
+ }
1209
+ toConstant(value) {
1210
+ return new BooleanConstantOperation(Boolean(value));
550
1211
  }
1212
+ /** Filter to rows where this attribute equals `value`. */
551
1213
  eq(value) {
552
1214
  return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new BooleanConstantOperation(value));
553
1215
  }
1216
+ /** Filter to rows where this attribute is true. */
554
1217
  isTrue() {
555
1218
  return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new BooleanConstantOperation(true));
556
1219
  }
1220
+ /** Filter to rows where this attribute is false. */
557
1221
  isFalse() {
558
1222
  return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new BooleanConstantOperation(false));
559
1223
  }
@@ -564,178 +1228,277 @@ function parseDate(value) {
564
1228
  if (isNaN(d.getTime())) throw new Error(`Cannot parse date: ${value}`);
565
1229
  return d;
566
1230
  }
1231
+ function temporalConstant(value) {
1232
+ if (typeof value === "string" && DATE_ONLY_PATTERN.test(value)) return new DateConstantOperation(new DateOnly(value));
1233
+ const date = parseDate(value);
1234
+ return date instanceof DateOnly ? new DateConstantOperation(date) : new DateTimeConstantOperation(date);
1235
+ }
567
1236
  var DateAttribute = class extends Attribute {
568
- constructor(displayName, columnName, columnDbType, owner, parent) {
569
- super(displayName, columnName, columnDbType, owner, parent);
1237
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded, nullable = true, optional = false) {
1238
+ super(displayName, columnName, columnDbType, owner, parent, embedded, nullable, optional);
1239
+ }
1240
+ toConstant(value) {
1241
+ return new DateConstantOperation(parseDate(value));
570
1242
  }
1243
+ /** Filter to rows where this date equals `value`. */
571
1244
  eq(value) {
572
1245
  return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new DateConstantOperation(parseDate(value)));
573
1246
  }
1247
+ /** Filter to rows where this date does not equal `value`. */
574
1248
  ne(value) {
575
1249
  return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new DateConstantOperation(parseDate(value)));
576
1250
  }
1251
+ /** Filter to rows where this date is after `value`. */
577
1252
  gt(value) {
578
1253
  return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, new DateConstantOperation(parseDate(value)));
579
1254
  }
1255
+ /** Filter to rows where this date is before `value`. */
580
1256
  lt(value) {
581
1257
  return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, new DateConstantOperation(parseDate(value)));
582
1258
  }
1259
+ /** Filter to rows where this date is on or after `value`. */
583
1260
  gte(value) {
584
1261
  return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, new DateConstantOperation(parseDate(value)));
585
1262
  }
1263
+ /** Filter to rows where this date is on or before `value`. */
586
1264
  lte(value) {
587
1265
  return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, new DateConstantOperation(parseDate(value)));
588
1266
  }
1267
+ /** Extract the four-digit calendar year. */
589
1268
  year() {
590
1269
  return new DateExtractOperation(this.cwj(), "YEAR" /* YEAR */, "Year " + this.displayName());
591
1270
  }
1271
+ /** Extract the month number (1–12). */
592
1272
  month() {
593
1273
  return new DateExtractOperation(this.cwj(), "MONTH" /* MONTH */, "Month " + this.displayName());
594
1274
  }
1275
+ /** Extract the day of the month (1–31). */
595
1276
  day() {
596
1277
  return new DateExtractOperation(this.cwj(), "DAY" /* DAY */, "Day " + this.displayName());
597
1278
  }
1279
+ /** Extract the quarter (1–4). */
598
1280
  quarter() {
599
1281
  return new DateExtractOperation(this.cwj(), "QUARTER" /* QUARTER */, "Quarter " + this.displayName());
600
1282
  }
1283
+ /** Extract the ISO week number (1–53). */
601
1284
  week() {
602
1285
  return new DateExtractOperation(this.cwj(), "WEEK" /* WEEK */, "Week " + this.displayName());
603
1286
  }
1287
+ /** Extract the day of the week (0 = Sunday through 6 = Saturday). */
604
1288
  dayOfWeek() {
605
1289
  return new DateExtractOperation(this.cwj(), "DOW" /* DOW */, "Day Of Week " + this.displayName());
606
1290
  }
1291
+ /** The date of the first day of the week the date falls in (a Monday). */
1292
+ firstDayOfWeek() {
1293
+ return new DateTruncOperation(this.cwj(), "WEEK" /* WEEK */, "First Day Of Week " + this.displayName());
1294
+ }
1295
+ /** The date of the first day of the month the date falls in. */
1296
+ firstDayOfMonth() {
1297
+ return new DateTruncOperation(this.cwj(), "MONTH" /* MONTH */, "First Day Of Month " + this.displayName());
1298
+ }
1299
+ /** The date of the first day of the quarter the date falls in. */
1300
+ firstDayOfQuarter() {
1301
+ return new DateTruncOperation(this.cwj(), "QUARTER" /* QUARTER */, "First Day Of Quarter " + this.displayName());
1302
+ }
1303
+ /** The date of the first day of the year the date falls in. */
1304
+ firstDayOfYear() {
1305
+ return new DateTruncOperation(this.cwj(), "YEAR" /* YEAR */, "First Day Of Year " + this.displayName());
1306
+ }
1307
+ /** Add `n` days to this date. */
607
1308
  addDays(n) {
608
1309
  return new DateArithmeticOperation(this.cwj(), n, "DAY" /* DAY */, true, "Add Days " + this.displayName());
609
1310
  }
1311
+ /** Add `n` months to this date. */
610
1312
  addMonths(n) {
611
1313
  return new DateArithmeticOperation(this.cwj(), n, "MONTH" /* MONTH */, true, "Add Months " + this.displayName());
612
1314
  }
1315
+ /** Add `n` years to this date. */
613
1316
  addYears(n) {
614
1317
  return new DateArithmeticOperation(this.cwj(), n, "YEAR" /* YEAR */, true, "Add Years " + this.displayName());
615
1318
  }
1319
+ /** Subtract `n` days from this date. */
616
1320
  subtractDays(n) {
617
1321
  return new DateArithmeticOperation(this.cwj(), n, "DAY" /* DAY */, false, "Subtract Days " + this.displayName());
618
1322
  }
1323
+ /** Subtract `n` months from this date. */
619
1324
  subtractMonths(n) {
620
1325
  return new DateArithmeticOperation(this.cwj(), n, "MONTH" /* MONTH */, false, "Subtract Months " + this.displayName());
621
1326
  }
1327
+ /** Subtract `n` years from this date. */
622
1328
  subtractYears(n) {
623
1329
  return new DateArithmeticOperation(this.cwj(), n, "YEAR" /* YEAR */, false, "Subtract Years " + this.displayName());
624
1330
  }
1331
+ /** Number of whole days between this date and `other`. */
625
1332
  diffDays(other) {
626
1333
  return new DateDiffOperation(this.cwj(), other, "DAY" /* DAY */, "Diff Days " + this.displayName());
627
1334
  }
1335
+ /** Number of whole months between this date and `other`. */
628
1336
  diffMonths(other) {
629
1337
  return new DateDiffOperation(this.cwj(), other, "MONTH" /* MONTH */, "Diff Months " + this.displayName());
630
1338
  }
1339
+ /** Number of whole years between this date and `other`. */
631
1340
  diffYears(other) {
632
1341
  return new DateDiffOperation(this.cwj(), other, "YEAR" /* YEAR */, "Diff Years " + this.displayName());
633
1342
  }
634
1343
  };
635
1344
  var DateTimeAttribute = class extends Attribute {
636
- constructor(displayName, columnName, columnDbType, owner, parent) {
637
- super(displayName, columnName, columnDbType, owner, parent);
1345
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded, nullable = true, optional = false) {
1346
+ super(displayName, columnName, columnDbType, owner, parent, embedded, nullable, optional);
638
1347
  }
1348
+ toConstant(value) {
1349
+ return temporalConstant(value);
1350
+ }
1351
+ /** Filter to rows where this timestamp equals `value`. */
639
1352
  eq(value) {
640
- return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new DateTimeConstantOperation(parseDate(value)));
1353
+ return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, temporalConstant(value));
641
1354
  }
1355
+ /** Filter to rows where this timestamp does not equal `value`. */
642
1356
  ne(value) {
643
- return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new DateTimeConstantOperation(parseDate(value)));
1357
+ return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, temporalConstant(value));
644
1358
  }
1359
+ /** Filter to rows where this timestamp is after `value`. */
645
1360
  gt(value) {
646
- return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, new DateTimeConstantOperation(parseDate(value)));
1361
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, temporalConstant(value));
647
1362
  }
1363
+ /** Filter to rows where this timestamp is before `value`. */
648
1364
  lt(value) {
649
- return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, new DateTimeConstantOperation(parseDate(value)));
1365
+ return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, temporalConstant(value));
650
1366
  }
1367
+ /** Filter to rows where this timestamp is on or after `value`. */
651
1368
  gte(value) {
652
- return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, new DateTimeConstantOperation(parseDate(value)));
1369
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, temporalConstant(value));
653
1370
  }
1371
+ /** Filter to rows where this timestamp is on or before `value`. */
654
1372
  lte(value) {
655
- return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, new DateTimeConstantOperation(parseDate(value)));
1373
+ return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, temporalConstant(value));
656
1374
  }
1375
+ /** Extract the four-digit calendar year. */
657
1376
  year() {
658
1377
  return new DateExtractOperation(this.cwj(), "YEAR" /* YEAR */, "Year " + this.displayName());
659
1378
  }
1379
+ /** Extract the month number (1–12). */
660
1380
  month() {
661
1381
  return new DateExtractOperation(this.cwj(), "MONTH" /* MONTH */, "Month " + this.displayName());
662
1382
  }
1383
+ /** Extract the day of the month (1–31). */
663
1384
  day() {
664
1385
  return new DateExtractOperation(this.cwj(), "DAY" /* DAY */, "Day " + this.displayName());
665
1386
  }
1387
+ /** Extract the hour (0–23). */
666
1388
  hour() {
667
1389
  return new DateExtractOperation(this.cwj(), "HOUR" /* HOUR */, "Hour " + this.displayName());
668
1390
  }
1391
+ /** Extract the minute (0–59). */
669
1392
  minute() {
670
1393
  return new DateExtractOperation(this.cwj(), "MINUTE" /* MINUTE */, "Minute " + this.displayName());
671
1394
  }
1395
+ /** Extract the second (0–59). */
672
1396
  second() {
673
1397
  return new DateExtractOperation(this.cwj(), "SECOND" /* SECOND */, "Second " + this.displayName());
674
1398
  }
1399
+ /** Extract the quarter (1–4). */
675
1400
  quarter() {
676
1401
  return new DateExtractOperation(this.cwj(), "QUARTER" /* QUARTER */, "Quarter " + this.displayName());
677
1402
  }
1403
+ /** Extract the ISO week number (1–53). */
678
1404
  week() {
679
1405
  return new DateExtractOperation(this.cwj(), "WEEK" /* WEEK */, "Week " + this.displayName());
680
1406
  }
1407
+ /** Extract the day of the week (0 = Sunday through 6 = Saturday). */
681
1408
  dayOfWeek() {
682
1409
  return new DateExtractOperation(this.cwj(), "DOW" /* DOW */, "Day Of Week " + this.displayName());
683
1410
  }
1411
+ /** The date of the first day of the week the date falls in (a Monday). */
1412
+ firstDayOfWeek() {
1413
+ return new DateTruncOperation(this.cwj(), "WEEK" /* WEEK */, "First Day Of Week " + this.displayName());
1414
+ }
1415
+ /** The date of the first day of the month the date falls in. */
1416
+ firstDayOfMonth() {
1417
+ return new DateTruncOperation(this.cwj(), "MONTH" /* MONTH */, "First Day Of Month " + this.displayName());
1418
+ }
1419
+ /** The date of the first day of the quarter the date falls in. */
1420
+ firstDayOfQuarter() {
1421
+ return new DateTruncOperation(this.cwj(), "QUARTER" /* QUARTER */, "First Day Of Quarter " + this.displayName());
1422
+ }
1423
+ /** The date of the first day of the year the date falls in. */
1424
+ firstDayOfYear() {
1425
+ return new DateTruncOperation(this.cwj(), "YEAR" /* YEAR */, "First Day Of Year " + this.displayName());
1426
+ }
1427
+ /** Add `n` days to this timestamp. */
684
1428
  addDays(n) {
685
1429
  return new DateArithmeticOperation(this.cwj(), n, "DAY" /* DAY */, true, "Add Days " + this.displayName());
686
1430
  }
1431
+ /** Add `n` months to this timestamp. */
687
1432
  addMonths(n) {
688
1433
  return new DateArithmeticOperation(this.cwj(), n, "MONTH" /* MONTH */, true, "Add Months " + this.displayName());
689
1434
  }
1435
+ /** Add `n` years to this timestamp. */
690
1436
  addYears(n) {
691
1437
  return new DateArithmeticOperation(this.cwj(), n, "YEAR" /* YEAR */, true, "Add Years " + this.displayName());
692
1438
  }
1439
+ /** Add `n` hours to this timestamp. */
693
1440
  addHours(n) {
694
1441
  return new DateArithmeticOperation(this.cwj(), n, "HOUR" /* HOUR */, true, "Add Hours " + this.displayName());
695
1442
  }
1443
+ /** Add `n` minutes to this timestamp. */
696
1444
  addMinutes(n) {
697
1445
  return new DateArithmeticOperation(this.cwj(), n, "MINUTE" /* MINUTE */, true, "Add Minutes " + this.displayName());
698
1446
  }
1447
+ /** Add `n` seconds to this timestamp. */
699
1448
  addSeconds(n) {
700
1449
  return new DateArithmeticOperation(this.cwj(), n, "SECOND" /* SECOND */, true, "Add Seconds " + this.displayName());
701
1450
  }
1451
+ /** Subtract `n` days from this timestamp. */
702
1452
  subtractDays(n) {
703
1453
  return new DateArithmeticOperation(this.cwj(), n, "DAY" /* DAY */, false, "Subtract Days " + this.displayName());
704
1454
  }
1455
+ /** Subtract `n` months from this timestamp. */
705
1456
  subtractMonths(n) {
706
1457
  return new DateArithmeticOperation(this.cwj(), n, "MONTH" /* MONTH */, false, "Subtract Months " + this.displayName());
707
1458
  }
1459
+ /** Subtract `n` years from this timestamp. */
708
1460
  subtractYears(n) {
709
1461
  return new DateArithmeticOperation(this.cwj(), n, "YEAR" /* YEAR */, false, "Subtract Years " + this.displayName());
710
1462
  }
1463
+ /** Subtract `n` hours from this timestamp. */
711
1464
  subtractHours(n) {
712
1465
  return new DateArithmeticOperation(this.cwj(), n, "HOUR" /* HOUR */, false, "Subtract Hours " + this.displayName());
713
1466
  }
1467
+ /** Subtract `n` minutes from this timestamp. */
714
1468
  subtractMinutes(n) {
715
1469
  return new DateArithmeticOperation(this.cwj(), n, "MINUTE" /* MINUTE */, false, "Subtract Minutes " + this.displayName());
716
1470
  }
1471
+ /** Subtract `n` seconds from this timestamp. */
717
1472
  subtractSeconds(n) {
718
1473
  return new DateArithmeticOperation(this.cwj(), n, "SECOND" /* SECOND */, false, "Subtract Seconds " + this.displayName());
719
1474
  }
1475
+ /** Number of whole days between this timestamp and `other`. */
720
1476
  diffDays(other) {
721
1477
  return new DateDiffOperation(this.cwj(), other, "DAY" /* DAY */, "Diff Days " + this.displayName());
722
1478
  }
1479
+ /** Number of whole months between this timestamp and `other`. */
723
1480
  diffMonths(other) {
724
1481
  return new DateDiffOperation(this.cwj(), other, "MONTH" /* MONTH */, "Diff Months " + this.displayName());
725
1482
  }
1483
+ /** Number of whole years between this timestamp and `other`. */
726
1484
  diffYears(other) {
727
1485
  return new DateDiffOperation(this.cwj(), other, "YEAR" /* YEAR */, "Diff Years " + this.displayName());
728
1486
  }
1487
+ /** Number of whole hours between this timestamp and `other`. */
729
1488
  diffHours(other) {
730
1489
  return new DateDiffOperation(this.cwj(), other, "HOUR" /* HOUR */, "Diff Hours " + this.displayName());
731
1490
  }
1491
+ /** Number of whole minutes between this timestamp and `other`. */
732
1492
  diffMinutes(other) {
733
1493
  return new DateDiffOperation(this.cwj(), other, "MINUTE" /* MINUTE */, "Diff Minutes " + this.displayName());
734
1494
  }
1495
+ /** Number of whole seconds between this timestamp and `other`. */
735
1496
  diffSeconds(other) {
736
1497
  return new DateDiffOperation(this.cwj(), other, "SECOND" /* SECOND */, "Diff Seconds " + this.displayName());
737
1498
  }
738
1499
  };
1500
+ applyMixins(DateAttribute, [MinMax]);
1501
+ applyMixins(DateTimeAttribute, [MinMax]);
739
1502
  // Annotate the CommonJS export names for ESM import in node:
740
1503
  0 && (module.exports = {
741
1504
  BooleanAttribute,