data-finder-ts 0.1.0 → 0.1.4

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 (64) hide show
  1. package/README.md +17 -55
  2. package/dist/chunk-4JVW4TAB.js +180 -0
  3. package/dist/chunk-4JVW4TAB.js.map +1 -0
  4. package/dist/chunk-4LNZV6EN.js +500 -0
  5. package/dist/chunk-4LNZV6EN.js.map +1 -0
  6. package/dist/chunk-FJYA2ASS.js +136 -0
  7. package/dist/chunk-FJYA2ASS.js.map +1 -0
  8. package/dist/chunk-FLEIUDZZ.js +14 -0
  9. package/dist/chunk-FLEIUDZZ.js.map +1 -0
  10. package/dist/chunk-MH4XMYVB.js +696 -0
  11. package/dist/chunk-MH4XMYVB.js.map +1 -0
  12. package/dist/chunk-PMPLCEWQ.js +90 -0
  13. package/dist/chunk-PMPLCEWQ.js.map +1 -0
  14. package/dist/chunk-UYMOE6YU.js +509 -0
  15. package/dist/chunk-UYMOE6YU.js.map +1 -0
  16. package/dist/datafinder/attribute.cjs +320 -0
  17. package/dist/datafinder/attribute.cjs.map +1 -0
  18. package/dist/datafinder/attribute.d.cts +86 -0
  19. package/dist/datafinder/attribute.d.ts +86 -0
  20. package/dist/datafinder/attribute.js +8 -0
  21. package/dist/datafinder/attribute.js.map +1 -0
  22. package/dist/datafinder/finder-registry.cjs +39 -0
  23. package/dist/datafinder/finder-registry.cjs.map +1 -0
  24. package/dist/datafinder/finder-registry.d.cts +4 -0
  25. package/dist/datafinder/finder-registry.d.ts +4 -0
  26. package/dist/datafinder/finder-registry.js +9 -0
  27. package/dist/datafinder/finder-registry.js.map +1 -0
  28. package/dist/datafinder/runner.cjs +1595 -0
  29. package/dist/datafinder/runner.cjs.map +1 -0
  30. package/dist/datafinder/runner.d.cts +44 -0
  31. package/dist/datafinder/runner.d.ts +44 -0
  32. package/dist/datafinder/runner.js +26 -0
  33. package/dist/datafinder/runner.js.map +1 -0
  34. package/dist/datafinder/sql-generator.cjs +1467 -0
  35. package/dist/datafinder/sql-generator.cjs.map +1 -0
  36. package/dist/datafinder/sql-generator.d.cts +8 -0
  37. package/dist/datafinder/sql-generator.d.ts +8 -0
  38. package/dist/datafinder/sql-generator.js +15 -0
  39. package/dist/datafinder/sql-generator.js.map +1 -0
  40. package/dist/datafinder/typed-attributes.cjs +909 -0
  41. package/dist/datafinder/typed-attributes.cjs.map +1 -0
  42. package/dist/datafinder/typed-attributes.d.cts +242 -0
  43. package/dist/datafinder/typed-attributes.d.ts +242 -0
  44. package/dist/datafinder/typed-attributes.js +25 -0
  45. package/dist/datafinder/typed-attributes.js.map +1 -0
  46. package/dist/index.cjs +2153 -0
  47. package/dist/index.cjs.map +1 -0
  48. package/dist/index.d.cts +28 -0
  49. package/dist/index.d.ts +28 -0
  50. package/dist/index.js +199 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/model/milestoning.cjs +145 -0
  53. package/dist/model/milestoning.cjs.map +1 -0
  54. package/dist/model/milestoning.d.cts +40 -0
  55. package/dist/model/milestoning.d.ts +40 -0
  56. package/dist/model/milestoning.js +18 -0
  57. package/dist/model/milestoning.js.map +1 -0
  58. package/dist/model/relational.cjs +579 -0
  59. package/dist/model/relational.cjs.map +1 -0
  60. package/dist/model/relational.d.cts +291 -0
  61. package/dist/model/relational.d.ts +291 -0
  62. package/dist/model/relational.js +99 -0
  63. package/dist/model/relational.js.map +1 -0
  64. package/package.json +6 -4
@@ -0,0 +1,909 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/datafinder/typed-attributes.ts
21
+ var typed_attributes_exports = {};
22
+ __export(typed_attributes_exports, {
23
+ BooleanAttribute: () => BooleanAttribute,
24
+ DateAttribute: () => DateAttribute,
25
+ DateTimeAttribute: () => DateTimeAttribute,
26
+ DecimalAttribute: () => DecimalAttribute,
27
+ DoubleAttribute: () => DoubleAttribute,
28
+ FloatAttribute: () => FloatAttribute,
29
+ IntegerAttribute: () => IntegerAttribute,
30
+ NumericAttribute: () => NumericAttribute,
31
+ StringAttribute: () => StringAttribute
32
+ });
33
+ module.exports = __toCommonJS(typed_attributes_exports);
34
+
35
+ // src/model/relational.ts
36
+ var RelationalOperationElement = class {
37
+ };
38
+ var Operation = class extends RelationalOperationElement {
39
+ andOp(other) {
40
+ return new LogicalOperation(this, "AND" /* AND */, other);
41
+ }
42
+ };
43
+ var ConstantOperation = class extends RelationalOperationElement {
44
+ };
45
+ var IntegerConstantOperation = class extends ConstantOperation {
46
+ constructor(value) {
47
+ super();
48
+ this.value = value;
49
+ }
50
+ value;
51
+ };
52
+ var FloatConstantOperation = class extends ConstantOperation {
53
+ constructor(value) {
54
+ super();
55
+ this.value = value;
56
+ }
57
+ value;
58
+ };
59
+ var StringConstantOperation = class extends ConstantOperation {
60
+ constructor(value) {
61
+ super();
62
+ this.value = value;
63
+ }
64
+ value;
65
+ };
66
+ var DateConstantOperation = class extends ConstantOperation {
67
+ constructor(value) {
68
+ super();
69
+ this.value = value;
70
+ }
71
+ value;
72
+ };
73
+ var DateTimeConstantOperation = class extends ConstantOperation {
74
+ constructor(value) {
75
+ super();
76
+ this.value = value;
77
+ }
78
+ value;
79
+ };
80
+ var DecimalConstantOperation = class extends ConstantOperation {
81
+ constructor(value) {
82
+ super();
83
+ this.value = value;
84
+ }
85
+ value;
86
+ };
87
+ var BooleanConstantOperation = class extends ConstantOperation {
88
+ constructor(value) {
89
+ super();
90
+ this.value = value;
91
+ }
92
+ value;
93
+ };
94
+ var UnaryOperation = class extends Operation {
95
+ constructor(element) {
96
+ super();
97
+ this.element = element;
98
+ }
99
+ element;
100
+ };
101
+ var BinaryOperation = class extends Operation {
102
+ constructor(left, right) {
103
+ super();
104
+ this.left = left;
105
+ this.right = right;
106
+ }
107
+ left;
108
+ right;
109
+ };
110
+ var IsNullOperation = class extends UnaryOperation {
111
+ };
112
+ var IsNotNullOperation = class extends UnaryOperation {
113
+ };
114
+ var ComparisonOperation = class extends BinaryOperation {
115
+ constructor(left, operator, right) {
116
+ super(left, right);
117
+ this.operator = operator;
118
+ }
119
+ operator;
120
+ };
121
+ var LogicalOperation = class extends BinaryOperation {
122
+ constructor(left, operator, right) {
123
+ super(left, right);
124
+ this.operator = operator;
125
+ }
126
+ operator;
127
+ };
128
+ var WindowSpecification = class {
129
+ constructor(partitionBy = [], orderBy = []) {
130
+ this.partitionBy = partitionBy;
131
+ this.orderBy = orderBy;
132
+ }
133
+ partitionBy;
134
+ orderBy;
135
+ };
136
+ var AggregateOperation = class _AggregateOperation extends UnaryOperation {
137
+ constructor(element, operator, displayName, window) {
138
+ super(element);
139
+ this.operator = operator;
140
+ this.displayName = displayName;
141
+ this.window = window;
142
+ }
143
+ operator;
144
+ displayName;
145
+ window;
146
+ over(partitionBy, orderBy) {
147
+ return new _AggregateOperation(
148
+ this.element,
149
+ this.operator,
150
+ this.displayName,
151
+ new WindowSpecification(partitionBy ?? [], orderBy ?? [])
152
+ );
153
+ }
154
+ };
155
+ var WindowFunctionOperation = class _WindowFunctionOperation extends UnaryOperation {
156
+ constructor(element, func, displayName, secondArg, extraArgs = [], window) {
157
+ super(element);
158
+ this.func = func;
159
+ this.displayName = displayName;
160
+ this.secondArg = secondArg;
161
+ this.extraArgs = extraArgs;
162
+ this.window = window;
163
+ }
164
+ func;
165
+ displayName;
166
+ secondArg;
167
+ extraArgs;
168
+ window;
169
+ over(partitionBy, orderBy) {
170
+ return new _WindowFunctionOperation(
171
+ this.element,
172
+ this.func,
173
+ this.displayName,
174
+ this.secondArg,
175
+ [...this.extraArgs],
176
+ new WindowSpecification(partitionBy ?? [], orderBy ?? [])
177
+ );
178
+ }
179
+ };
180
+ var ScalarFunctionOperation = class extends UnaryOperation {
181
+ constructor(element, func, displayName, secondArg, extraArgs = []) {
182
+ super(element);
183
+ this.func = func;
184
+ this.displayName = displayName;
185
+ this.secondArg = secondArg;
186
+ this.extraArgs = extraArgs;
187
+ }
188
+ func;
189
+ displayName;
190
+ secondArg;
191
+ extraArgs;
192
+ };
193
+ var DateExtractOperation = class extends UnaryOperation {
194
+ constructor(element, part, displayName) {
195
+ super(element);
196
+ this.part = part;
197
+ this.displayName = displayName;
198
+ }
199
+ part;
200
+ displayName;
201
+ };
202
+ var DateArithmeticOperation = class extends UnaryOperation {
203
+ constructor(element, n, unit, isAdd = true, displayName) {
204
+ super(element);
205
+ this.n = n;
206
+ this.unit = unit;
207
+ this.isAdd = isAdd;
208
+ this.displayName = displayName;
209
+ }
210
+ n;
211
+ unit;
212
+ isAdd;
213
+ displayName;
214
+ };
215
+ var DateDiffOperation = class extends UnaryOperation {
216
+ constructor(element, other, unit, displayName) {
217
+ super(element);
218
+ this.other = other;
219
+ this.unit = unit;
220
+ this.displayName = displayName;
221
+ }
222
+ other;
223
+ unit;
224
+ displayName;
225
+ };
226
+ var Column = class extends RelationalOperationElement {
227
+ constructor(name, type, owner, primaryKey = false) {
228
+ super();
229
+ this.name = name;
230
+ this.type = type;
231
+ this.owner = owner;
232
+ this.primaryKey = primaryKey;
233
+ }
234
+ name;
235
+ type;
236
+ owner;
237
+ primaryKey;
238
+ table;
239
+ };
240
+ var ColumnWithJoin = class extends RelationalOperationElement {
241
+ /**
242
+ * `embedded` is an alternate reference to a flat (denormalized) column on the owning table that
243
+ * holds the same value without the join; the SQL generator uses it when the join can be elided.
244
+ */
245
+ constructor(column, parent, embedded) {
246
+ super();
247
+ this.column = column;
248
+ this.parent = parent;
249
+ this.embedded = embedded;
250
+ }
251
+ column;
252
+ parent;
253
+ embedded;
254
+ };
255
+ var SortOperation = class {
256
+ constructor(column, direction) {
257
+ this.column = column;
258
+ this.direction = direction;
259
+ }
260
+ column;
261
+ direction;
262
+ };
263
+
264
+ // src/datafinder/attribute.ts
265
+ var Attribute = class _Attribute {
266
+ _displayName;
267
+ _column;
268
+ _owner;
269
+ _parent;
270
+ _embedded;
271
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded) {
272
+ this._displayName = displayName;
273
+ this._column = new Column(columnName, columnDbType, owner);
274
+ this._owner = owner;
275
+ this._parent = parent;
276
+ this._embedded = embedded;
277
+ }
278
+ column() {
279
+ return this._column;
280
+ }
281
+ owner() {
282
+ return this._owner;
283
+ }
284
+ parent() {
285
+ return this._parent;
286
+ }
287
+ displayName() {
288
+ return this._displayName;
289
+ }
290
+ /** Alternate attribute on a flat column of the owning table, used in place of this one when its join is elided. */
291
+ embedded() {
292
+ return this._embedded;
293
+ }
294
+ cwj() {
295
+ return new ColumnWithJoin(this._column, this._parent, this._embedded?.cwj());
296
+ }
297
+ /** Count the number of non-null values. Use in a projection with `groupByOp` to aggregate per group. */
298
+ count() {
299
+ return new AggregateOperation(
300
+ this.cwj(),
301
+ "COUNT" /* COUNT */,
302
+ this._displayName + " Count"
303
+ );
304
+ }
305
+ /** Sort this attribute in ascending order. Pass to `orderByOp` or a window function's `orderBy`. */
306
+ ascending() {
307
+ return new SortOperation(this.cwj(), "ASC" /* ASC */);
308
+ }
309
+ /** Sort this attribute in descending order. Pass to `orderByOp` or a window function's `orderBy`. */
310
+ descending() {
311
+ return new SortOperation(this.cwj(), "DESC" /* DESC */);
312
+ }
313
+ /** Filter to rows where this attribute has no value. */
314
+ isNull() {
315
+ return new IsNullOperation(this.cwj());
316
+ }
317
+ /** Filter to rows where this attribute has a value. */
318
+ isNotNull() {
319
+ return new IsNotNullOperation(this.cwj());
320
+ }
321
+ _windowSpec(partitionBy, orderBy) {
322
+ const pbArr = partitionBy === void 0 ? [] : Array.isArray(partitionBy) ? partitionBy : [partitionBy];
323
+ const pb = pbArr.map((x) => x instanceof _Attribute ? x.cwj() : x);
324
+ const ob = orderBy === void 0 ? [] : Array.isArray(orderBy) ? orderBy : [orderBy];
325
+ return new WindowSpecification(pb, ob);
326
+ }
327
+ /**
328
+ * Assign a rank to each row within the ordered window, following pandas `Series.rank` conventions.
329
+ *
330
+ * `method` controls tie-breaking (default `'min'`):
331
+ * - `'min'` — tied rows share the lowest rank; the next rank skips.
332
+ * - `'dense'` — like `'min'` but ranks are contiguous (no gaps).
333
+ * - `'first'` — each row gets a unique sequential integer (no ties).
334
+ * - `'max'` — only meaningful with `pct: true` (see below).
335
+ *
336
+ * When `pct: true` the result is a relative rank between 0 and 1:
337
+ * - `method: 'min'` (default) → fraction of values strictly below this row (PERCENT_RANK).
338
+ * - `method: 'max'` → fraction of values at or below this row (cumulative distribution).
339
+ *
340
+ * `partitionBy` restarts the ranking within each group of distinct values.
341
+ */
342
+ rank(opts = {}) {
343
+ const { method = "min", pct = false, partitionBy, orderBy } = opts;
344
+ let func;
345
+ let name;
346
+ if (pct) {
347
+ if (method === "max") {
348
+ func = "CUME_DIST" /* CUME_DIST */;
349
+ name = "Cume Dist";
350
+ } else {
351
+ func = "PERCENT_RANK" /* PERCENT_RANK */;
352
+ name = "Percent Rank";
353
+ }
354
+ } else if (method === "first") {
355
+ func = "ROW_NUMBER" /* ROW_NUMBER */;
356
+ name = "Row Number";
357
+ } else if (method === "dense") {
358
+ func = "DENSE_RANK" /* DENSE_RANK */;
359
+ name = "Dense Rank";
360
+ } else {
361
+ func = "RANK" /* RANK */;
362
+ name = "Rank";
363
+ }
364
+ return new WindowFunctionOperation(null, func, name, void 0, [], this._windowSpec(partitionBy, orderBy));
365
+ }
366
+ /**
367
+ * Split rows into `buckets` equal-sized quantile bins ordered by `orderBy`.
368
+ * Each row receives a bucket number from 1 (lowest) to `buckets` (highest).
369
+ * Named after `pandas.qcut`.
370
+ */
371
+ qcut(buckets, opts = {}) {
372
+ return new WindowFunctionOperation(
373
+ null,
374
+ "NTILE" /* NTILE */,
375
+ "Quantile",
376
+ buckets,
377
+ [],
378
+ this._windowSpec(opts.partitionBy, opts.orderBy)
379
+ );
380
+ }
381
+ /**
382
+ * Return the value of this attribute from `periods` rows earlier (positive) or later (negative)
383
+ * within the ordered window, following `pandas.Series.shift`.
384
+ * Rows with no neighbour at the given offset return `null` (or `fillValue` if provided).
385
+ */
386
+ shift(periods = 1, opts = {}) {
387
+ const extraArgs = opts.fillValue !== void 0 ? [opts.fillValue] : [];
388
+ const func = periods >= 0 ? "LAG" /* LAG */ : "LEAD" /* LEAD */;
389
+ const label = periods >= 0 ? "Lag" : "Lead";
390
+ return new WindowFunctionOperation(
391
+ this.cwj(),
392
+ func,
393
+ label + " " + this._displayName,
394
+ Math.abs(periods),
395
+ extraArgs,
396
+ this._windowSpec(opts.partitionBy, opts.orderBy)
397
+ );
398
+ }
399
+ /**
400
+ * Return the first value of this attribute in the window frame.
401
+ * Use `partitionBy` to restart the frame for each group.
402
+ */
403
+ first(opts = {}) {
404
+ return new WindowFunctionOperation(
405
+ this.cwj(),
406
+ "FIRST_VALUE" /* FIRST_VALUE */,
407
+ "First " + this._displayName,
408
+ void 0,
409
+ [],
410
+ this._windowSpec(opts.partitionBy, opts.orderBy)
411
+ );
412
+ }
413
+ /**
414
+ * Return the last value of this attribute in the window frame.
415
+ * Use `partitionBy` to restart the frame for each group.
416
+ */
417
+ last(opts = {}) {
418
+ return new WindowFunctionOperation(
419
+ this.cwj(),
420
+ "LAST_VALUE" /* LAST_VALUE */,
421
+ "Last " + this._displayName,
422
+ void 0,
423
+ [],
424
+ this._windowSpec(opts.partitionBy, opts.orderBy)
425
+ );
426
+ }
427
+ };
428
+
429
+ // src/datafinder/typed-attributes.ts
430
+ var StringAttribute = class extends Attribute {
431
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded) {
432
+ super(displayName, columnName, columnDbType, owner, parent, embedded);
433
+ }
434
+ /** Convert every character to uppercase. */
435
+ toUpperCase() {
436
+ return new ScalarFunctionOperation(this.cwj(), "UPPER" /* UPPER */, "Upper " + this.displayName());
437
+ }
438
+ /** Convert every character to lowercase. */
439
+ toLowerCase() {
440
+ return new ScalarFunctionOperation(this.cwj(), "LOWER" /* LOWER */, "Lower " + this.displayName());
441
+ }
442
+ /** Remove leading and trailing whitespace. */
443
+ trim() {
444
+ return new ScalarFunctionOperation(this.cwj(), "TRIM" /* TRIM */, "Trim " + this.displayName());
445
+ }
446
+ /** Remove leading whitespace. */
447
+ trimStart() {
448
+ return new ScalarFunctionOperation(this.cwj(), "LTRIM" /* LTRIM */, "Trim Start " + this.displayName());
449
+ }
450
+ /** Remove trailing whitespace. */
451
+ trimEnd() {
452
+ return new ScalarFunctionOperation(this.cwj(), "RTRIM" /* RTRIM */, "Trim End " + this.displayName());
453
+ }
454
+ /** Return the number of characters in the string. */
455
+ length() {
456
+ return new ScalarFunctionOperation(this.cwj(), "LENGTH" /* LENGTH */, "Length " + this.displayName());
457
+ }
458
+ /** Return the string with characters in reverse order. */
459
+ reverse() {
460
+ return new ScalarFunctionOperation(this.cwj(), "REVERSE" /* REVERSE */, "Reverse " + this.displayName());
461
+ }
462
+ /** Return the first `n` characters. */
463
+ left(n) {
464
+ return new ScalarFunctionOperation(this.cwj(), "LEFT" /* LEFT */, "Left " + this.displayName(), n);
465
+ }
466
+ /** Return the last `n` characters. */
467
+ right(n) {
468
+ return new ScalarFunctionOperation(this.cwj(), "RIGHT" /* RIGHT */, "Right " + this.displayName(), n);
469
+ }
470
+ /** Return the string repeated `n` times. */
471
+ repeat(n) {
472
+ return new ScalarFunctionOperation(this.cwj(), "REPEAT" /* REPEAT */, "Repeat " + this.displayName(), n);
473
+ }
474
+ /** Replace all occurrences of `fromStr` with `toStr`. */
475
+ replace(fromStr, toStr) {
476
+ return new ScalarFunctionOperation(this.cwj(), "REPLACE" /* REPLACE */, "Replace " + this.displayName(), void 0, [fromStr, toStr]);
477
+ }
478
+ /**
479
+ * Extract a portion of the string.
480
+ * `start` is zero-based (following Python convention); `length` is optional.
481
+ */
482
+ substring(start, length) {
483
+ const args = length !== void 0 ? [start + 1, length] : [start + 1];
484
+ return new ScalarFunctionOperation(this.cwj(), "SUBSTRING" /* SUBSTRING */, "Substring " + this.displayName(), void 0, args);
485
+ }
486
+ /** Filter to rows where this attribute equals `value`. */
487
+ eq(value) {
488
+ return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new StringConstantOperation(value));
489
+ }
490
+ /** Filter to rows where this attribute does not equal `value`. */
491
+ ne(value) {
492
+ return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new StringConstantOperation(value));
493
+ }
494
+ /** Filter to rows where this attribute contains `value` as a substring. */
495
+ contains(value) {
496
+ return new ComparisonOperation(this.cwj(), "LIKE" /* LIKE */, new StringConstantOperation(`%${value}%`));
497
+ }
498
+ /** Filter to rows where this attribute begins with `prefix`. */
499
+ startsWith(prefix) {
500
+ return new ComparisonOperation(this.cwj(), "LIKE" /* LIKE */, new StringConstantOperation(`${prefix}%`));
501
+ }
502
+ /** Filter to rows where this attribute ends with `suffix`. */
503
+ endsWith(suffix) {
504
+ return new ComparisonOperation(this.cwj(), "LIKE" /* LIKE */, new StringConstantOperation(`%${suffix}`));
505
+ }
506
+ /** Filter to rows where this attribute does not contain `value` as a substring. */
507
+ notContains(value) {
508
+ return new ComparisonOperation(this.cwj(), "NOT_LIKE" /* NOT_LIKE */, new StringConstantOperation(`%${value}%`));
509
+ }
510
+ };
511
+ var NumericAttribute = class extends Attribute {
512
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded) {
513
+ super(displayName, columnName, columnDbType, owner, parent, embedded);
514
+ }
515
+ /** Sum of all values in the group. */
516
+ sum() {
517
+ return new AggregateOperation(this.cwj(), "SUM" /* SUM */, "Sum " + this.displayName());
518
+ }
519
+ /** Smallest value in the group. */
520
+ min() {
521
+ return new AggregateOperation(this.cwj(), "MIN" /* MIN */, "Min " + this.displayName());
522
+ }
523
+ /** Largest value in the group. */
524
+ max() {
525
+ return new AggregateOperation(this.cwj(), "MAX" /* MAX */, "Max " + this.displayName());
526
+ }
527
+ /** Arithmetic mean of all values in the group. */
528
+ average() {
529
+ return new AggregateOperation(this.cwj(), "AVERAGE" /* AVERAGE */, "Average " + this.displayName());
530
+ }
531
+ /** Absolute value (distance from zero, always non-negative). */
532
+ abs() {
533
+ return new ScalarFunctionOperation(this.cwj(), "ABS" /* ABS */, "Abs " + this.displayName());
534
+ }
535
+ /** Round up to the nearest integer. */
536
+ ceil() {
537
+ return new ScalarFunctionOperation(this.cwj(), "CEILING" /* CEILING */, "Ceil " + this.displayName());
538
+ }
539
+ /** Round down to the nearest integer. */
540
+ floor() {
541
+ return new ScalarFunctionOperation(this.cwj(), "FLOOR" /* FLOOR */, "Floor " + this.displayName());
542
+ }
543
+ /** Square root. */
544
+ sqrt() {
545
+ return new ScalarFunctionOperation(this.cwj(), "SQRT" /* SQRT */, "Sqrt " + this.displayName());
546
+ }
547
+ /** Remainder after dividing by `n`. */
548
+ mod(n) {
549
+ return new ScalarFunctionOperation(this.cwj(), "MOD" /* MOD */, "Mod " + this.displayName(), n);
550
+ }
551
+ /** Raise to the power of `n`. */
552
+ power(n) {
553
+ return new ScalarFunctionOperation(this.cwj(), "POWER" /* POWER */, "Power " + this.displayName(), n);
554
+ }
555
+ /** Round to `d` decimal places, or to the nearest integer when `d` is omitted. */
556
+ round(d) {
557
+ return new ScalarFunctionOperation(this.cwj(), "ROUND" /* ROUND */, "Round " + this.displayName(), d);
558
+ }
559
+ };
560
+ var DoubleAttribute = class extends NumericAttribute {
561
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded) {
562
+ super(displayName, columnName, columnDbType, owner, parent, embedded);
563
+ }
564
+ /** Filter to rows where this attribute equals `value`. */
565
+ eq(value) {
566
+ return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new FloatConstantOperation(value));
567
+ }
568
+ /** Filter to rows where this attribute does not equal `value`. */
569
+ ne(value) {
570
+ return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new FloatConstantOperation(value));
571
+ }
572
+ /** Filter to rows where this attribute is greater than `value`. */
573
+ gt(value) {
574
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, new FloatConstantOperation(value));
575
+ }
576
+ /** Filter to rows where this attribute is less than `value`. */
577
+ lt(value) {
578
+ return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, new FloatConstantOperation(value));
579
+ }
580
+ /** Filter to rows where this attribute is greater than or equal to `value`. */
581
+ gte(value) {
582
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, new FloatConstantOperation(value));
583
+ }
584
+ /** Filter to rows where this attribute is less than or equal to `value`. */
585
+ lte(value) {
586
+ return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, new FloatConstantOperation(value));
587
+ }
588
+ };
589
+ var FloatAttribute = DoubleAttribute;
590
+ var DecimalAttribute = class extends NumericAttribute {
591
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded) {
592
+ super(displayName, columnName, columnDbType, owner, parent, embedded);
593
+ }
594
+ /** Filter to rows where this attribute equals `value`. */
595
+ eq(value) {
596
+ return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new DecimalConstantOperation(value));
597
+ }
598
+ /** Filter to rows where this attribute does not equal `value`. */
599
+ ne(value) {
600
+ return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new DecimalConstantOperation(value));
601
+ }
602
+ /** Filter to rows where this attribute is greater than `value`. */
603
+ gt(value) {
604
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, new DecimalConstantOperation(value));
605
+ }
606
+ /** Filter to rows where this attribute is less than `value`. */
607
+ lt(value) {
608
+ return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, new DecimalConstantOperation(value));
609
+ }
610
+ /** Filter to rows where this attribute is greater than or equal to `value`. */
611
+ gte(value) {
612
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, new DecimalConstantOperation(value));
613
+ }
614
+ /** Filter to rows where this attribute is less than or equal to `value`. */
615
+ lte(value) {
616
+ return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, new DecimalConstantOperation(value));
617
+ }
618
+ };
619
+ var IntegerAttribute = class extends NumericAttribute {
620
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded) {
621
+ super(displayName, columnName, columnDbType, owner, parent, embedded);
622
+ }
623
+ /** Filter to rows where this attribute equals `value`. */
624
+ eq(value) {
625
+ return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new IntegerConstantOperation(value));
626
+ }
627
+ /** Filter to rows where this attribute does not equal `value`. */
628
+ ne(value) {
629
+ return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new IntegerConstantOperation(value));
630
+ }
631
+ /** Filter to rows where this attribute is greater than `value`. */
632
+ gt(value) {
633
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, new IntegerConstantOperation(value));
634
+ }
635
+ /** Filter to rows where this attribute is less than `value`. */
636
+ lt(value) {
637
+ return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, new IntegerConstantOperation(value));
638
+ }
639
+ /** Filter to rows where this attribute is greater than or equal to `value`. */
640
+ gte(value) {
641
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, new IntegerConstantOperation(value));
642
+ }
643
+ /** Filter to rows where this attribute is less than or equal to `value`. */
644
+ lte(value) {
645
+ return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, new IntegerConstantOperation(value));
646
+ }
647
+ };
648
+ var BooleanAttribute = class extends Attribute {
649
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded) {
650
+ super(displayName, columnName, columnDbType, owner, parent, embedded);
651
+ }
652
+ /** Filter to rows where this attribute equals `value`. */
653
+ eq(value) {
654
+ return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new BooleanConstantOperation(value));
655
+ }
656
+ /** Filter to rows where this attribute is true. */
657
+ isTrue() {
658
+ return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new BooleanConstantOperation(true));
659
+ }
660
+ /** Filter to rows where this attribute is false. */
661
+ isFalse() {
662
+ return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new BooleanConstantOperation(false));
663
+ }
664
+ };
665
+ function parseDate(value) {
666
+ if (value instanceof Date) return value;
667
+ const d = new Date(value);
668
+ if (isNaN(d.getTime())) throw new Error(`Cannot parse date: ${value}`);
669
+ return d;
670
+ }
671
+ var DateAttribute = class extends Attribute {
672
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded) {
673
+ super(displayName, columnName, columnDbType, owner, parent, embedded);
674
+ }
675
+ /** Filter to rows where this date equals `value`. */
676
+ eq(value) {
677
+ return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new DateConstantOperation(parseDate(value)));
678
+ }
679
+ /** Filter to rows where this date does not equal `value`. */
680
+ ne(value) {
681
+ return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new DateConstantOperation(parseDate(value)));
682
+ }
683
+ /** Filter to rows where this date is after `value`. */
684
+ gt(value) {
685
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, new DateConstantOperation(parseDate(value)));
686
+ }
687
+ /** Filter to rows where this date is before `value`. */
688
+ lt(value) {
689
+ return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, new DateConstantOperation(parseDate(value)));
690
+ }
691
+ /** Filter to rows where this date is on or after `value`. */
692
+ gte(value) {
693
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, new DateConstantOperation(parseDate(value)));
694
+ }
695
+ /** Filter to rows where this date is on or before `value`. */
696
+ lte(value) {
697
+ return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, new DateConstantOperation(parseDate(value)));
698
+ }
699
+ /** Extract the four-digit calendar year. */
700
+ year() {
701
+ return new DateExtractOperation(this.cwj(), "YEAR" /* YEAR */, "Year " + this.displayName());
702
+ }
703
+ /** Extract the month number (1–12). */
704
+ month() {
705
+ return new DateExtractOperation(this.cwj(), "MONTH" /* MONTH */, "Month " + this.displayName());
706
+ }
707
+ /** Extract the day of the month (1–31). */
708
+ day() {
709
+ return new DateExtractOperation(this.cwj(), "DAY" /* DAY */, "Day " + this.displayName());
710
+ }
711
+ /** Extract the quarter (1–4). */
712
+ quarter() {
713
+ return new DateExtractOperation(this.cwj(), "QUARTER" /* QUARTER */, "Quarter " + this.displayName());
714
+ }
715
+ /** Extract the ISO week number (1–53). */
716
+ week() {
717
+ return new DateExtractOperation(this.cwj(), "WEEK" /* WEEK */, "Week " + this.displayName());
718
+ }
719
+ /** Extract the day of the week (0 = Sunday through 6 = Saturday). */
720
+ dayOfWeek() {
721
+ return new DateExtractOperation(this.cwj(), "DOW" /* DOW */, "Day Of Week " + this.displayName());
722
+ }
723
+ /** Add `n` days to this date. */
724
+ addDays(n) {
725
+ return new DateArithmeticOperation(this.cwj(), n, "DAY" /* DAY */, true, "Add Days " + this.displayName());
726
+ }
727
+ /** Add `n` months to this date. */
728
+ addMonths(n) {
729
+ return new DateArithmeticOperation(this.cwj(), n, "MONTH" /* MONTH */, true, "Add Months " + this.displayName());
730
+ }
731
+ /** Add `n` years to this date. */
732
+ addYears(n) {
733
+ return new DateArithmeticOperation(this.cwj(), n, "YEAR" /* YEAR */, true, "Add Years " + this.displayName());
734
+ }
735
+ /** Subtract `n` days from this date. */
736
+ subtractDays(n) {
737
+ return new DateArithmeticOperation(this.cwj(), n, "DAY" /* DAY */, false, "Subtract Days " + this.displayName());
738
+ }
739
+ /** Subtract `n` months from this date. */
740
+ subtractMonths(n) {
741
+ return new DateArithmeticOperation(this.cwj(), n, "MONTH" /* MONTH */, false, "Subtract Months " + this.displayName());
742
+ }
743
+ /** Subtract `n` years from this date. */
744
+ subtractYears(n) {
745
+ return new DateArithmeticOperation(this.cwj(), n, "YEAR" /* YEAR */, false, "Subtract Years " + this.displayName());
746
+ }
747
+ /** Number of whole days between this date and `other`. */
748
+ diffDays(other) {
749
+ return new DateDiffOperation(this.cwj(), other, "DAY" /* DAY */, "Diff Days " + this.displayName());
750
+ }
751
+ /** Number of whole months between this date and `other`. */
752
+ diffMonths(other) {
753
+ return new DateDiffOperation(this.cwj(), other, "MONTH" /* MONTH */, "Diff Months " + this.displayName());
754
+ }
755
+ /** Number of whole years between this date and `other`. */
756
+ diffYears(other) {
757
+ return new DateDiffOperation(this.cwj(), other, "YEAR" /* YEAR */, "Diff Years " + this.displayName());
758
+ }
759
+ };
760
+ var DateTimeAttribute = class extends Attribute {
761
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded) {
762
+ super(displayName, columnName, columnDbType, owner, parent, embedded);
763
+ }
764
+ /** Filter to rows where this timestamp equals `value`. */
765
+ eq(value) {
766
+ return new ComparisonOperation(this.cwj(), "EQUAL" /* EQUAL */, new DateTimeConstantOperation(parseDate(value)));
767
+ }
768
+ /** Filter to rows where this timestamp does not equal `value`. */
769
+ ne(value) {
770
+ return new ComparisonOperation(this.cwj(), "NOT_EQUAL" /* NOT_EQUAL */, new DateTimeConstantOperation(parseDate(value)));
771
+ }
772
+ /** Filter to rows where this timestamp is after `value`. */
773
+ gt(value) {
774
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN" /* GREATER_THAN */, new DateTimeConstantOperation(parseDate(value)));
775
+ }
776
+ /** Filter to rows where this timestamp is before `value`. */
777
+ lt(value) {
778
+ return new ComparisonOperation(this.cwj(), "LESS_THAN" /* LESS_THAN */, new DateTimeConstantOperation(parseDate(value)));
779
+ }
780
+ /** Filter to rows where this timestamp is on or after `value`. */
781
+ gte(value) {
782
+ return new ComparisonOperation(this.cwj(), "GREATER_THAN_OR_EQUAL_TO" /* GREATER_THAN_OR_EQUAL_TO */, new DateTimeConstantOperation(parseDate(value)));
783
+ }
784
+ /** Filter to rows where this timestamp is on or before `value`. */
785
+ lte(value) {
786
+ return new ComparisonOperation(this.cwj(), "LESS_THAN_OR_EQUAL_TO" /* LESS_THAN_OR_EQUAL_TO */, new DateTimeConstantOperation(parseDate(value)));
787
+ }
788
+ /** Extract the four-digit calendar year. */
789
+ year() {
790
+ return new DateExtractOperation(this.cwj(), "YEAR" /* YEAR */, "Year " + this.displayName());
791
+ }
792
+ /** Extract the month number (1–12). */
793
+ month() {
794
+ return new DateExtractOperation(this.cwj(), "MONTH" /* MONTH */, "Month " + this.displayName());
795
+ }
796
+ /** Extract the day of the month (1–31). */
797
+ day() {
798
+ return new DateExtractOperation(this.cwj(), "DAY" /* DAY */, "Day " + this.displayName());
799
+ }
800
+ /** Extract the hour (0–23). */
801
+ hour() {
802
+ return new DateExtractOperation(this.cwj(), "HOUR" /* HOUR */, "Hour " + this.displayName());
803
+ }
804
+ /** Extract the minute (0–59). */
805
+ minute() {
806
+ return new DateExtractOperation(this.cwj(), "MINUTE" /* MINUTE */, "Minute " + this.displayName());
807
+ }
808
+ /** Extract the second (0–59). */
809
+ second() {
810
+ return new DateExtractOperation(this.cwj(), "SECOND" /* SECOND */, "Second " + this.displayName());
811
+ }
812
+ /** Extract the quarter (1–4). */
813
+ quarter() {
814
+ return new DateExtractOperation(this.cwj(), "QUARTER" /* QUARTER */, "Quarter " + this.displayName());
815
+ }
816
+ /** Extract the ISO week number (1–53). */
817
+ week() {
818
+ return new DateExtractOperation(this.cwj(), "WEEK" /* WEEK */, "Week " + this.displayName());
819
+ }
820
+ /** Extract the day of the week (0 = Sunday through 6 = Saturday). */
821
+ dayOfWeek() {
822
+ return new DateExtractOperation(this.cwj(), "DOW" /* DOW */, "Day Of Week " + this.displayName());
823
+ }
824
+ /** Add `n` days to this timestamp. */
825
+ addDays(n) {
826
+ return new DateArithmeticOperation(this.cwj(), n, "DAY" /* DAY */, true, "Add Days " + this.displayName());
827
+ }
828
+ /** Add `n` months to this timestamp. */
829
+ addMonths(n) {
830
+ return new DateArithmeticOperation(this.cwj(), n, "MONTH" /* MONTH */, true, "Add Months " + this.displayName());
831
+ }
832
+ /** Add `n` years to this timestamp. */
833
+ addYears(n) {
834
+ return new DateArithmeticOperation(this.cwj(), n, "YEAR" /* YEAR */, true, "Add Years " + this.displayName());
835
+ }
836
+ /** Add `n` hours to this timestamp. */
837
+ addHours(n) {
838
+ return new DateArithmeticOperation(this.cwj(), n, "HOUR" /* HOUR */, true, "Add Hours " + this.displayName());
839
+ }
840
+ /** Add `n` minutes to this timestamp. */
841
+ addMinutes(n) {
842
+ return new DateArithmeticOperation(this.cwj(), n, "MINUTE" /* MINUTE */, true, "Add Minutes " + this.displayName());
843
+ }
844
+ /** Add `n` seconds to this timestamp. */
845
+ addSeconds(n) {
846
+ return new DateArithmeticOperation(this.cwj(), n, "SECOND" /* SECOND */, true, "Add Seconds " + this.displayName());
847
+ }
848
+ /** Subtract `n` days from this timestamp. */
849
+ subtractDays(n) {
850
+ return new DateArithmeticOperation(this.cwj(), n, "DAY" /* DAY */, false, "Subtract Days " + this.displayName());
851
+ }
852
+ /** Subtract `n` months from this timestamp. */
853
+ subtractMonths(n) {
854
+ return new DateArithmeticOperation(this.cwj(), n, "MONTH" /* MONTH */, false, "Subtract Months " + this.displayName());
855
+ }
856
+ /** Subtract `n` years from this timestamp. */
857
+ subtractYears(n) {
858
+ return new DateArithmeticOperation(this.cwj(), n, "YEAR" /* YEAR */, false, "Subtract Years " + this.displayName());
859
+ }
860
+ /** Subtract `n` hours from this timestamp. */
861
+ subtractHours(n) {
862
+ return new DateArithmeticOperation(this.cwj(), n, "HOUR" /* HOUR */, false, "Subtract Hours " + this.displayName());
863
+ }
864
+ /** Subtract `n` minutes from this timestamp. */
865
+ subtractMinutes(n) {
866
+ return new DateArithmeticOperation(this.cwj(), n, "MINUTE" /* MINUTE */, false, "Subtract Minutes " + this.displayName());
867
+ }
868
+ /** Subtract `n` seconds from this timestamp. */
869
+ subtractSeconds(n) {
870
+ return new DateArithmeticOperation(this.cwj(), n, "SECOND" /* SECOND */, false, "Subtract Seconds " + this.displayName());
871
+ }
872
+ /** Number of whole days between this timestamp and `other`. */
873
+ diffDays(other) {
874
+ return new DateDiffOperation(this.cwj(), other, "DAY" /* DAY */, "Diff Days " + this.displayName());
875
+ }
876
+ /** Number of whole months between this timestamp and `other`. */
877
+ diffMonths(other) {
878
+ return new DateDiffOperation(this.cwj(), other, "MONTH" /* MONTH */, "Diff Months " + this.displayName());
879
+ }
880
+ /** Number of whole years between this timestamp and `other`. */
881
+ diffYears(other) {
882
+ return new DateDiffOperation(this.cwj(), other, "YEAR" /* YEAR */, "Diff Years " + this.displayName());
883
+ }
884
+ /** Number of whole hours between this timestamp and `other`. */
885
+ diffHours(other) {
886
+ return new DateDiffOperation(this.cwj(), other, "HOUR" /* HOUR */, "Diff Hours " + this.displayName());
887
+ }
888
+ /** Number of whole minutes between this timestamp and `other`. */
889
+ diffMinutes(other) {
890
+ return new DateDiffOperation(this.cwj(), other, "MINUTE" /* MINUTE */, "Diff Minutes " + this.displayName());
891
+ }
892
+ /** Number of whole seconds between this timestamp and `other`. */
893
+ diffSeconds(other) {
894
+ return new DateDiffOperation(this.cwj(), other, "SECOND" /* SECOND */, "Diff Seconds " + this.displayName());
895
+ }
896
+ };
897
+ // Annotate the CommonJS export names for ESM import in node:
898
+ 0 && (module.exports = {
899
+ BooleanAttribute,
900
+ DateAttribute,
901
+ DateTimeAttribute,
902
+ DecimalAttribute,
903
+ DoubleAttribute,
904
+ FloatAttribute,
905
+ IntegerAttribute,
906
+ NumericAttribute,
907
+ StringAttribute
908
+ });
909
+ //# sourceMappingURL=typed-attributes.cjs.map