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.
- package/README.md +17 -55
- package/dist/chunk-BGEX377Q.js +230 -0
- package/dist/chunk-BGEX377Q.js.map +1 -0
- package/dist/chunk-BKPWV3OF.js +962 -0
- package/dist/chunk-BKPWV3OF.js.map +1 -0
- package/dist/{chunk-EYXBYV2X.js → chunk-GPHWC533.js} +2 -2
- package/dist/chunk-KAK75RVS.js +198 -0
- package/dist/chunk-KAK75RVS.js.map +1 -0
- package/dist/chunk-MGEL5RWM.js +628 -0
- package/dist/chunk-MGEL5RWM.js.map +1 -0
- package/dist/chunk-PF6EJZHB.js +1015 -0
- package/dist/chunk-PF6EJZHB.js.map +1 -0
- package/dist/datafinder/attribute.cjs +595 -18
- package/dist/datafinder/attribute.cjs.map +1 -1
- package/dist/datafinder/attribute.d.cts +73 -10
- package/dist/datafinder/attribute.d.ts +73 -10
- package/dist/datafinder/attribute.js +2 -2
- package/dist/datafinder/runner.cjs +1589 -288
- package/dist/datafinder/runner.cjs.map +1 -1
- package/dist/datafinder/runner.d.cts +41 -7
- package/dist/datafinder/runner.d.ts +41 -7
- package/dist/datafinder/runner.js +12 -6
- package/dist/datafinder/sql-generator.cjs +1484 -281
- package/dist/datafinder/sql-generator.cjs.map +1 -1
- package/dist/datafinder/sql-generator.d.cts +19 -14
- package/dist/datafinder/sql-generator.d.ts +19 -14
- package/dist/datafinder/sql-generator.js +9 -7
- package/dist/datafinder/typed-attributes.cjs +856 -93
- package/dist/datafinder/typed-attributes.cjs.map +1 -1
- package/dist/datafinder/typed-attributes.d.cts +3 -135
- package/dist/datafinder/typed-attributes.d.ts +3 -135
- package/dist/datafinder/typed-attributes.js +3 -3
- package/dist/dialect-CogGPm_y.d.cts +38 -0
- package/dist/dialect-aaG1bDi5.d.ts +38 -0
- package/dist/index.cjs +2080 -480
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -14
- package/dist/index.d.ts +119 -14
- package/dist/index.js +362 -12
- package/dist/index.js.map +1 -1
- package/dist/model/milestoning.cjs +529 -0
- package/dist/model/milestoning.cjs.map +1 -1
- package/dist/model/milestoning.js +2 -2
- package/dist/model/relational.cjs +608 -12
- package/dist/model/relational.cjs.map +1 -1
- package/dist/model/relational.d.cts +456 -47
- package/dist/model/relational.d.ts +456 -47
- package/dist/model/relational.js +61 -3
- package/dist/typed-attributes-CUTf_6Ru.d.ts +328 -0
- package/dist/typed-attributes-CdWXq_78.d.cts +328 -0
- package/package.json +5 -2
- package/dist/chunk-3SSWFES4.js +0 -448
- package/dist/chunk-3SSWFES4.js.map +0 -1
- package/dist/chunk-5K2Z3YDY.js +0 -393
- package/dist/chunk-5K2Z3YDY.js.map +0 -1
- package/dist/chunk-6QTCGJWX.js +0 -98
- package/dist/chunk-6QTCGJWX.js.map +0 -1
- package/dist/chunk-DFYZVBII.js +0 -652
- package/dist/chunk-DFYZVBII.js.map +0 -1
- package/dist/chunk-V647VNMY.js +0 -135
- package/dist/chunk-V647VNMY.js.map +0 -1
- /package/dist/{chunk-EYXBYV2X.js.map → chunk-GPHWC533.js.map} +0 -0
|
@@ -8,6 +8,13 @@ declare enum ComparisonOperator {
|
|
|
8
8
|
LIKE = "LIKE",
|
|
9
9
|
NOT_LIKE = "NOT_LIKE"
|
|
10
10
|
}
|
|
11
|
+
/** The character that makes the next one literal in a LIKE pattern built from a value (`contains`, `startsWith`, ...). */
|
|
12
|
+
declare const LIKE_ESCAPE = "!";
|
|
13
|
+
/**
|
|
14
|
+
* `value` as part of a LIKE pattern that matches it literally: `%`, `_` and the escape character itself
|
|
15
|
+
* would otherwise be wildcards.
|
|
16
|
+
*/
|
|
17
|
+
declare function escapeLike(value: string): string;
|
|
11
18
|
declare enum LogicalOperator {
|
|
12
19
|
AND = "AND",
|
|
13
20
|
OR = "OR"
|
|
@@ -17,7 +24,15 @@ declare enum AggregateOperator {
|
|
|
17
24
|
SUM = "SUM",
|
|
18
25
|
MIN = "MIN",
|
|
19
26
|
MAX = "MAX",
|
|
20
|
-
AVERAGE = "AVERAGE"
|
|
27
|
+
AVERAGE = "AVERAGE",
|
|
28
|
+
STRING_AGG = "STRING_AGG",
|
|
29
|
+
COUNT_DISTINCT = "COUNT_DISTINCT",
|
|
30
|
+
STDDEV_SAMP = "STDDEV_SAMP",
|
|
31
|
+
STDDEV_POP = "STDDEV_POP",
|
|
32
|
+
VAR_SAMP = "VAR_SAMP",
|
|
33
|
+
VAR_POP = "VAR_POP",
|
|
34
|
+
BOOL_AND = "BOOL_AND",
|
|
35
|
+
BOOL_OR = "BOOL_OR"
|
|
21
36
|
}
|
|
22
37
|
declare enum ScalarFunction {
|
|
23
38
|
ABS = "ABS",
|
|
@@ -38,7 +53,8 @@ declare enum ScalarFunction {
|
|
|
38
53
|
RIGHT = "RIGHT",
|
|
39
54
|
REPEAT = "REPEAT",
|
|
40
55
|
REPLACE = "REPLACE",
|
|
41
|
-
SUBSTRING = "SUBSTRING"
|
|
56
|
+
SUBSTRING = "SUBSTRING",
|
|
57
|
+
COALESCE = "COALESCE"
|
|
42
58
|
}
|
|
43
59
|
declare enum DatePart {
|
|
44
60
|
YEAR = "YEAR",
|
|
@@ -57,19 +73,37 @@ declare enum SortDirection {
|
|
|
57
73
|
}
|
|
58
74
|
declare abstract class RelationalOperationElement {
|
|
59
75
|
}
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Something that can be a column of the result, so can be given a name there:
|
|
78
|
+
* `f.price().sum().alias('Total')`. The name is held by an `Alias` that wraps the column.
|
|
79
|
+
*/
|
|
80
|
+
interface Aliasable {
|
|
81
|
+
alias(name: string): Alias;
|
|
82
|
+
}
|
|
83
|
+
/** Something the result can be ordered by: `f.id().count().ascending()`. */
|
|
84
|
+
interface Sortable {
|
|
85
|
+
/** Sort by this expression, smallest first. */
|
|
86
|
+
ascending(): SortOperation;
|
|
87
|
+
/** Sort by this expression, largest first. */
|
|
88
|
+
descending(): SortOperation;
|
|
89
|
+
}
|
|
90
|
+
declare abstract class Operation extends RelationalOperationElement implements Aliasable {
|
|
91
|
+
/** Name this column in the result: `f.price().sum().alias('Total')`, `f.age().gt(30).alias('Adult')`. */
|
|
92
|
+
alias(name: string): Alias;
|
|
93
|
+
and(other: RelationalOperationElement): Operation;
|
|
94
|
+
/** Combine with `other` using OR. A chain reads left to right: `a.or(b).and(c)` is `(a OR b) AND c`. */
|
|
95
|
+
or(other: RelationalOperationElement): Operation;
|
|
62
96
|
}
|
|
63
97
|
declare class NoOperation extends Operation {
|
|
64
|
-
|
|
98
|
+
and(other: RelationalOperationElement): Operation;
|
|
99
|
+
/** No filter matches every row, so OR-ing anything with it still matches every row. */
|
|
100
|
+
or(_other: RelationalOperationElement): Operation;
|
|
65
101
|
}
|
|
66
|
-
declare
|
|
67
|
-
}
|
|
68
|
-
declare class IntegerConstantOperation extends ConstantOperation {
|
|
102
|
+
declare class IntegerConstantOperation extends NumericConstantOperation {
|
|
69
103
|
readonly value: number;
|
|
70
104
|
constructor(value: number);
|
|
71
105
|
}
|
|
72
|
-
declare class FloatConstantOperation extends
|
|
106
|
+
declare class FloatConstantOperation extends NumericConstantOperation {
|
|
73
107
|
readonly value: number;
|
|
74
108
|
constructor(value: number);
|
|
75
109
|
}
|
|
@@ -77,6 +111,15 @@ declare class StringConstantOperation extends ConstantOperation {
|
|
|
77
111
|
readonly value: string;
|
|
78
112
|
constructor(value: string);
|
|
79
113
|
}
|
|
114
|
+
/** Matches a zone-less calendar date such as `2024-06-01`. */
|
|
115
|
+
declare const DATE_ONLY_PATTERN: RegExp;
|
|
116
|
+
/**
|
|
117
|
+
* A calendar date, held as UTC midnight. JavaScript has no date-only type, so this marks a `Date`
|
|
118
|
+
* that was given as a date rather than a timestamp, and is rendered as a date literal (`'2024-06-01'`)
|
|
119
|
+
* instead of a timestamp literal (`'2024-06-01 00:00:00'`).
|
|
120
|
+
*/
|
|
121
|
+
declare class DateOnly extends Date {
|
|
122
|
+
}
|
|
80
123
|
declare class DateConstantOperation extends ConstantOperation {
|
|
81
124
|
readonly value: Date;
|
|
82
125
|
constructor(value: Date);
|
|
@@ -85,7 +128,7 @@ declare class DateTimeConstantOperation extends ConstantOperation {
|
|
|
85
128
|
readonly value: Date;
|
|
86
129
|
constructor(value: Date);
|
|
87
130
|
}
|
|
88
|
-
declare class DecimalConstantOperation extends
|
|
131
|
+
declare class DecimalConstantOperation extends NumericConstantOperation {
|
|
89
132
|
readonly value: number;
|
|
90
133
|
constructor(value: number);
|
|
91
134
|
}
|
|
@@ -102,30 +145,11 @@ declare abstract class BinaryOperation extends Operation {
|
|
|
102
145
|
readonly right: RelationalOperationElement;
|
|
103
146
|
constructor(left: RelationalOperationElement, right: RelationalOperationElement);
|
|
104
147
|
}
|
|
105
|
-
declare class IsNullOperation extends UnaryOperation {
|
|
106
|
-
}
|
|
107
|
-
declare class IsNotNullOperation extends UnaryOperation {
|
|
108
|
-
}
|
|
109
|
-
declare class ComparisonOperation extends BinaryOperation {
|
|
110
|
-
readonly operator: ComparisonOperator;
|
|
111
|
-
constructor(left: RelationalOperationElement, operator: ComparisonOperator, right: RelationalOperationElement);
|
|
112
|
-
}
|
|
113
|
-
declare class LogicalOperation extends BinaryOperation {
|
|
114
|
-
readonly operator: LogicalOperator;
|
|
115
|
-
constructor(left: RelationalOperationElement, operator: LogicalOperator, right: RelationalOperationElement);
|
|
116
|
-
}
|
|
117
148
|
declare class WindowSpecification {
|
|
118
149
|
readonly partitionBy: RelationalOperationElement[];
|
|
119
150
|
readonly orderBy: SortOperation[];
|
|
120
151
|
constructor(partitionBy?: RelationalOperationElement[], orderBy?: SortOperation[]);
|
|
121
152
|
}
|
|
122
|
-
declare class AggregateOperation extends UnaryOperation {
|
|
123
|
-
readonly operator: AggregateOperator;
|
|
124
|
-
readonly displayName?: string | undefined;
|
|
125
|
-
readonly window?: WindowSpecification | undefined;
|
|
126
|
-
constructor(element: RelationalOperationElement, operator: AggregateOperator, displayName?: string | undefined, window?: WindowSpecification | undefined);
|
|
127
|
-
over(partitionBy?: RelationalOperationElement[], orderBy?: SortOperation[]): AggregateOperation;
|
|
128
|
-
}
|
|
129
153
|
declare enum WindowFunction {
|
|
130
154
|
ROW_NUMBER = "ROW_NUMBER",
|
|
131
155
|
RANK = "RANK",
|
|
@@ -138,38 +162,49 @@ declare enum WindowFunction {
|
|
|
138
162
|
CUME_DIST = "CUME_DIST",
|
|
139
163
|
PERCENT_RANK = "PERCENT_RANK"
|
|
140
164
|
}
|
|
141
|
-
declare class WindowFunctionOperation extends UnaryOperation {
|
|
165
|
+
declare class WindowFunctionOperation extends UnaryOperation implements Sortable {
|
|
142
166
|
readonly func: WindowFunction;
|
|
143
167
|
readonly displayName?: string | undefined;
|
|
144
168
|
readonly secondArg?: number | undefined;
|
|
145
169
|
readonly extraArgs: (string | number)[];
|
|
146
170
|
readonly window?: WindowSpecification | undefined;
|
|
171
|
+
/** Sort by this expression, smallest first. */
|
|
172
|
+
ascending(): SortOperation;
|
|
173
|
+
/** Sort by this expression, largest first. */
|
|
174
|
+
descending(): SortOperation;
|
|
147
175
|
constructor(element: RelationalOperationElement | null, func: WindowFunction, displayName?: string | undefined, secondArg?: number | undefined, extraArgs?: (string | number)[], window?: WindowSpecification | undefined);
|
|
148
176
|
over(partitionBy?: RelationalOperationElement[], orderBy?: SortOperation[]): WindowFunctionOperation;
|
|
149
177
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
readonly secondArg?: number | undefined;
|
|
154
|
-
readonly extraArgs: (string | number)[];
|
|
155
|
-
constructor(element: RelationalOperationElement, func: ScalarFunction, displayName?: string | undefined, secondArg?: number | undefined, extraArgs?: (string | number)[]);
|
|
156
|
-
}
|
|
157
|
-
declare class DateExtractOperation extends UnaryOperation {
|
|
178
|
+
/** The functions that give a number, which arithmetic and `Numeric` functions apply to. */
|
|
179
|
+
declare const NUMERIC_FUNCTIONS: ReadonlySet<ScalarFunction>;
|
|
180
|
+
declare class DateExtractOperation extends UnaryOperation implements Sortable {
|
|
158
181
|
readonly part: DatePart;
|
|
159
182
|
readonly displayName?: string | undefined;
|
|
183
|
+
/** Sort by this expression, smallest first. */
|
|
184
|
+
ascending(): SortOperation;
|
|
185
|
+
/** Sort by this expression, largest first. */
|
|
186
|
+
descending(): SortOperation;
|
|
160
187
|
constructor(element: RelationalOperationElement, part: DatePart, displayName?: string | undefined);
|
|
161
188
|
}
|
|
162
|
-
declare class DateArithmeticOperation extends UnaryOperation {
|
|
189
|
+
declare class DateArithmeticOperation extends UnaryOperation implements Sortable {
|
|
163
190
|
readonly n: number;
|
|
164
191
|
readonly unit: DatePart;
|
|
165
192
|
readonly isAdd: boolean;
|
|
166
193
|
readonly displayName?: string | undefined;
|
|
194
|
+
/** Sort by this expression, smallest first. */
|
|
195
|
+
ascending(): SortOperation;
|
|
196
|
+
/** Sort by this expression, largest first. */
|
|
197
|
+
descending(): SortOperation;
|
|
167
198
|
constructor(element: RelationalOperationElement, n: number, unit: DatePart, isAdd?: boolean, displayName?: string | undefined);
|
|
168
199
|
}
|
|
169
|
-
declare class DateDiffOperation extends UnaryOperation {
|
|
200
|
+
declare class DateDiffOperation extends UnaryOperation implements Sortable {
|
|
170
201
|
readonly other: Date;
|
|
171
202
|
readonly unit: DatePart;
|
|
172
203
|
readonly displayName?: string | undefined;
|
|
204
|
+
/** Sort by this expression, smallest first. */
|
|
205
|
+
ascending(): SortOperation;
|
|
206
|
+
/** Sort by this expression, largest first. */
|
|
207
|
+
descending(): SortOperation;
|
|
173
208
|
constructor(element: RelationalOperationElement, other: Date, unit: DatePart, displayName?: string | undefined);
|
|
174
209
|
}
|
|
175
210
|
declare class Column extends RelationalOperationElement {
|
|
@@ -178,7 +213,9 @@ declare class Column extends RelationalOperationElement {
|
|
|
178
213
|
readonly owner?: string | undefined;
|
|
179
214
|
readonly primaryKey: boolean;
|
|
180
215
|
table?: Table;
|
|
181
|
-
|
|
216
|
+
/** Whether the column may hold NULL. As in Legend, a primary key is never null. */
|
|
217
|
+
readonly nullable: boolean;
|
|
218
|
+
constructor(name: string, type: string, owner?: string | undefined, primaryKey?: boolean, nullable?: boolean);
|
|
182
219
|
}
|
|
183
220
|
declare class ForeignKey {
|
|
184
221
|
readonly column: Column;
|
|
@@ -221,26 +258,398 @@ declare class JoinOperation {
|
|
|
221
258
|
readonly left: Column;
|
|
222
259
|
readonly right: Column;
|
|
223
260
|
filter?: RelationalOperationElement;
|
|
261
|
+
/** Property-equality filters on the join target (property id -> value), set by a related finder given a filter. */
|
|
262
|
+
filterKwargs: Record<string, unknown>;
|
|
263
|
+
/** Maps property ids to [column, type, table] for `filterKwargs`. */
|
|
264
|
+
filterColumnMap: Record<string, [string, string, string]>;
|
|
224
265
|
constructor(name: string, target: Table, left: Column, right: Column, filter?: RelationalOperationElement);
|
|
225
266
|
}
|
|
226
267
|
declare class JoinTreeNodeOperation {
|
|
227
268
|
readonly join: JoinOperation;
|
|
228
269
|
readonly parent?: JoinTreeNodeOperation | undefined;
|
|
229
|
-
|
|
270
|
+
/**
|
|
271
|
+
* True when the property this step follows is to-many, so a value read through it repeats the row. As in
|
|
272
|
+
* Pure, that is the multiplicity of the property, not something the join itself says.
|
|
273
|
+
*/
|
|
274
|
+
readonly many: boolean;
|
|
275
|
+
/** True when the property this step follows can be missing (its lower bound is 0). */
|
|
276
|
+
readonly optional: boolean;
|
|
277
|
+
constructor(join: JoinOperation, parent?: JoinTreeNodeOperation | undefined,
|
|
278
|
+
/**
|
|
279
|
+
* True when the property this step follows is to-many, so a value read through it repeats the row. As in
|
|
280
|
+
* Pure, that is the multiplicity of the property, not something the join itself says.
|
|
281
|
+
*/
|
|
282
|
+
many?: boolean,
|
|
283
|
+
/** True when the property this step follows can be missing (its lower bound is 0). */
|
|
284
|
+
optional?: boolean);
|
|
230
285
|
}
|
|
231
286
|
declare class ColumnWithJoin extends RelationalOperationElement {
|
|
232
287
|
readonly column: Column;
|
|
233
288
|
readonly parent?: JoinTreeNodeOperation | undefined;
|
|
234
|
-
|
|
289
|
+
readonly embedded?: ColumnWithJoin | undefined;
|
|
290
|
+
private readonly _optional;
|
|
291
|
+
/**
|
|
292
|
+
* `embedded` is an alternate reference to a flat (denormalized) column on the owning table that
|
|
293
|
+
* holds the same value without the join; the SQL generator uses it when the join can be elided.
|
|
294
|
+
*/
|
|
295
|
+
constructor(column: Column, parent?: JoinTreeNodeOperation | undefined, embedded?: ColumnWithJoin | undefined, _optional?: boolean);
|
|
296
|
+
/** Whether the value can be missing: its property is optional, or a navigation on the way to it is. */
|
|
297
|
+
get optional(): boolean;
|
|
235
298
|
}
|
|
236
299
|
declare class SortOperation {
|
|
237
|
-
|
|
300
|
+
/** What the rows are ordered by: a column, or an expression such as an aggregate. */
|
|
301
|
+
readonly column: RelationalOperationElement;
|
|
238
302
|
readonly direction: SortDirection;
|
|
239
|
-
constructor(
|
|
303
|
+
constructor(
|
|
304
|
+
/** What the rows are ordered by: a column, or an expression such as an aggregate. */
|
|
305
|
+
column: RelationalOperationElement, direction: SortDirection);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* A column of the result under another name, wrapping the column it names. Only things that can be a
|
|
309
|
+
* column of the result have `alias()` (an `Attribute`, an aggregate, a function, a constant, ...), so a
|
|
310
|
+
* filter cannot be aliased; aliasing an alias replaces its name.
|
|
311
|
+
*/
|
|
312
|
+
declare class Alias extends RelationalOperationElement implements Aliasable, Sortable {
|
|
313
|
+
readonly element: RelationalOperationElement;
|
|
314
|
+
readonly name: string;
|
|
315
|
+
constructor(element: RelationalOperationElement, name: string);
|
|
316
|
+
alias(name: string): Alias;
|
|
317
|
+
/** Sorts by the column the alias names. */
|
|
318
|
+
ascending(): SortOperation;
|
|
319
|
+
/** Sorts by the column the alias names. */
|
|
320
|
+
descending(): SortOperation;
|
|
321
|
+
}
|
|
322
|
+
/** Returned by `RelatedFinder.exists()`. A backend translates it to a join-presence check. */
|
|
323
|
+
declare class ExistsOperation extends RelationalOperationElement implements Aliasable {
|
|
324
|
+
readonly node: JoinTreeNodeOperation;
|
|
325
|
+
/** Name this column in the result. */
|
|
326
|
+
alias(name: string): Alias;
|
|
327
|
+
constructor(node: JoinTreeNodeOperation);
|
|
328
|
+
and(other: RelationalOperationElement): LogicalOperation;
|
|
329
|
+
or(other: RelationalOperationElement): LogicalOperation;
|
|
330
|
+
}
|
|
331
|
+
/** Returned by `RelatedFinder.notExists()`. A backend translates it to a join-absence check. */
|
|
332
|
+
declare class NotExistsOperation extends RelationalOperationElement implements Aliasable {
|
|
333
|
+
readonly node: JoinTreeNodeOperation;
|
|
334
|
+
/** Name this column in the result. */
|
|
335
|
+
alias(name: string): Alias;
|
|
336
|
+
constructor(node: JoinTreeNodeOperation);
|
|
337
|
+
and(other: RelationalOperationElement): LogicalOperation;
|
|
338
|
+
or(other: RelationalOperationElement): LogicalOperation;
|
|
339
|
+
}
|
|
340
|
+
declare class SelectOperation {
|
|
341
|
+
readonly display: RelationalOperationElement[];
|
|
342
|
+
readonly filter: RelationalOperationElement;
|
|
343
|
+
readonly orderBy: SortOperation[];
|
|
344
|
+
readonly groupBy: RelationalOperationElement[];
|
|
345
|
+
readonly limit?: number | undefined;
|
|
346
|
+
readonly table?: Table | undefined;
|
|
347
|
+
/**
|
|
348
|
+
* Extra ON conditions for this query's joins (milestoning and property filters), keyed by join node.
|
|
349
|
+
* Held here rather than on the shared JoinOperation, so queries that use the same node can't affect each other.
|
|
350
|
+
*/
|
|
351
|
+
readonly joinFilters: ReadonlyMap<JoinTreeNodeOperation, Operation>;
|
|
352
|
+
/** Whether each distinct row is returned once (`SELECT DISTINCT`). */
|
|
353
|
+
readonly distinct: boolean;
|
|
354
|
+
/** How many rows to skip before the first one returned. */
|
|
355
|
+
readonly offset?: number | undefined;
|
|
356
|
+
/** Keeps the groups that satisfy it (`HAVING`). */
|
|
357
|
+
readonly having?: Operation | undefined;
|
|
358
|
+
constructor(display: RelationalOperationElement[], filter: RelationalOperationElement, orderBy?: SortOperation[], groupBy?: RelationalOperationElement[], limit?: number | undefined, table?: Table | undefined,
|
|
359
|
+
/**
|
|
360
|
+
* Extra ON conditions for this query's joins (milestoning and property filters), keyed by join node.
|
|
361
|
+
* Held here rather than on the shared JoinOperation, so queries that use the same node can't affect each other.
|
|
362
|
+
*/
|
|
363
|
+
joinFilters?: ReadonlyMap<JoinTreeNodeOperation, Operation>,
|
|
364
|
+
/** Whether each distinct row is returned once (`SELECT DISTINCT`). */
|
|
365
|
+
distinct?: boolean,
|
|
366
|
+
/** How many rows to skip before the first one returned. */
|
|
367
|
+
offset?: number | undefined,
|
|
368
|
+
/** Keeps the groups that satisfy it (`HAVING`). */
|
|
369
|
+
having?: Operation | undefined);
|
|
370
|
+
}
|
|
371
|
+
/** Whether `op` holds an aggregate, a window function or a count. */
|
|
372
|
+
declare function containsAggregateOrWindow(op: unknown): boolean;
|
|
373
|
+
/** Whether `op` collapses rows: an aggregate or a count. Window functions keep every row. */
|
|
374
|
+
declare function containsAggregate(op: unknown): boolean;
|
|
375
|
+
/** A plain value as the constant it compares with. */
|
|
376
|
+
declare function valueOperand(value: unknown): ConstantOperation;
|
|
377
|
+
/** The thing to compare or calculate with: an expression as it is, an attribute as its column, a value as a constant. */
|
|
378
|
+
declare function operandOf(other: unknown): RelationalOperationElement;
|
|
379
|
+
/**
|
|
380
|
+
* Comparisons for an expression, as for a column: `f.name().toUpperCase().eq('ACME')`, `f.name().length().gt(10)`.
|
|
381
|
+
* The other side is a value or another expression. Each gives a filter. Mixed into the expressions that have it.
|
|
382
|
+
*/
|
|
383
|
+
declare abstract class Comparable {
|
|
384
|
+
abstract comparisonOperand(): RelationalOperationElement;
|
|
385
|
+
private _compared;
|
|
386
|
+
/** Filter to rows where this expression equals `other`. */
|
|
387
|
+
eq(other: unknown): ComparisonOperation;
|
|
388
|
+
/** Filter to rows where this expression does not equal `other`. */
|
|
389
|
+
ne(other: unknown): ComparisonOperation;
|
|
390
|
+
/** Filter to rows where this expression is less than `other`. */
|
|
391
|
+
lt(other: unknown): ComparisonOperation;
|
|
392
|
+
/** Filter to rows where this expression is at most `other`. */
|
|
393
|
+
lte(other: unknown): ComparisonOperation;
|
|
394
|
+
/** Filter to rows where this expression is greater than `other`. */
|
|
395
|
+
gt(other: unknown): ComparisonOperation;
|
|
396
|
+
/** Filter to rows where this expression is at least `other`. */
|
|
397
|
+
gte(other: unknown): ComparisonOperation;
|
|
398
|
+
}
|
|
399
|
+
/** Whether a standard deviation or variance is the sample one (`ddof` 1) or the population one (0). */
|
|
400
|
+
declare function sample(ddof: number): boolean;
|
|
401
|
+
/**
|
|
402
|
+
* Pattern tests on an expression that holds text, as on a column: `f.name().toUpperCase().startsWith('AC')`,
|
|
403
|
+
* `f.name().join(',').contains('John')`. Mixed into the expressions that have it.
|
|
404
|
+
*/
|
|
405
|
+
declare abstract class StringPredicates {
|
|
406
|
+
abstract comparisonOperand(): RelationalOperationElement;
|
|
407
|
+
private _like;
|
|
408
|
+
/** Filter to rows where this text contains `value`. */
|
|
409
|
+
contains(value: string): ComparisonOperation;
|
|
410
|
+
/** Filter to rows where this text starts with `prefix`. */
|
|
411
|
+
startsWith(prefix: string): ComparisonOperation;
|
|
412
|
+
/** Filter to rows where this text ends with `suffix`. */
|
|
413
|
+
endsWith(suffix: string): ComparisonOperation;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Aggregates of an expression, as a column has them: `f.price().times(f.quantity()).sum()`, `constant(1).sum()`,
|
|
417
|
+
* `when(f.price().gt(10)).then(5.0).otherwise(1.0).sum()`. Mixed into the expressions that have it.
|
|
418
|
+
*/
|
|
419
|
+
declare abstract class Aggregates {
|
|
420
|
+
private _aggregate;
|
|
421
|
+
/** Sum of the values in the group. */
|
|
422
|
+
sum(): AggregateOperation;
|
|
423
|
+
/** Smallest value in the group. */
|
|
424
|
+
min(): AggregateOperation;
|
|
425
|
+
/** Largest value in the group. */
|
|
426
|
+
max(): AggregateOperation;
|
|
427
|
+
/** Arithmetic mean of the values in the group. */
|
|
428
|
+
average(): AggregateOperation;
|
|
429
|
+
/** Number of non-null values in the group. */
|
|
430
|
+
count(): AggregateOperation;
|
|
431
|
+
/** Standard deviation of the values in the group: the sample one by default, `ddof = 0` for the population one. */
|
|
432
|
+
std(ddof?: number): AggregateOperation;
|
|
433
|
+
/** Variance of the values in the group: the sample one by default, `ddof = 0` for the population one. */
|
|
434
|
+
var(ddof?: number): AggregateOperation;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Aggregates of a condition: `f.quantity().gt(20).all()` is true for a group where every row holds, `.any()` where at
|
|
438
|
+
* least one does. Mixed into the conditions.
|
|
439
|
+
*/
|
|
440
|
+
declare abstract class BooleanAggregates {
|
|
441
|
+
/** True for a group where every row satisfies the condition. */
|
|
442
|
+
all(): AggregateOperation;
|
|
443
|
+
/** True for a group where at least one row satisfies the condition. */
|
|
444
|
+
any(): AggregateOperation;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Mix the methods of the base classes into `derived`, the TypeScript handbook's way to inherit from more than
|
|
448
|
+
* one class: the type side comes from an `interface Derived extends Base {}` beside the class.
|
|
449
|
+
*/
|
|
450
|
+
declare function applyMixins(derived: {
|
|
451
|
+
prototype: object;
|
|
452
|
+
}, bases: {
|
|
453
|
+
prototype: object;
|
|
454
|
+
}[]): void;
|
|
455
|
+
declare enum ArithmeticOperator {
|
|
456
|
+
ADD = "+",
|
|
457
|
+
SUBTRACT = "-",
|
|
458
|
+
MULTIPLY = "*",
|
|
459
|
+
DIVIDE = "/"
|
|
460
|
+
}
|
|
461
|
+
/** A number or a numeric expression: what arithmetic takes on the other side. */
|
|
462
|
+
type ArithmeticOperand = number | {
|
|
463
|
+
arithmeticOperand(): RelationalOperationElement;
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* `plus`, `minus`, `times` and `dividedBy` for an expression that holds a number: `f.price().times(f.quantity())`,
|
|
467
|
+
* `f.price().plus(1.5)`, `constant(100).minus(f.price())`. The other operand is a number or another numeric
|
|
468
|
+
* expression. Mixed into the expressions that have it.
|
|
469
|
+
*/
|
|
470
|
+
declare abstract class Arithmetic {
|
|
471
|
+
abstract arithmeticOperand(): RelationalOperationElement;
|
|
472
|
+
/** Raises if this expression is not a number. */
|
|
473
|
+
assertNumeric(): void;
|
|
474
|
+
private _arithmetic;
|
|
475
|
+
/** `this + other`. */
|
|
476
|
+
plus(other: ArithmeticOperand): ArithmeticOperation;
|
|
477
|
+
/** `this - other`. */
|
|
478
|
+
minus(other: ArithmeticOperand): ArithmeticOperation;
|
|
479
|
+
/** `this * other`. */
|
|
480
|
+
times(other: ArithmeticOperand): ArithmeticOperation;
|
|
481
|
+
/** `this / other`. */
|
|
482
|
+
dividedBy(other: ArithmeticOperand): ArithmeticOperation;
|
|
483
|
+
}
|
|
484
|
+
/** What can be joined as text: a string, a text column, a function that gives text, or another concatenation. */
|
|
485
|
+
type ConcatPart = string | {
|
|
486
|
+
functionInput(): RelationalOperationElement;
|
|
487
|
+
} | ConcatOperation;
|
|
488
|
+
/**
|
|
489
|
+
* Join text: `concat(f.name(), ' (', f.category(), ')')`. A string is a constant; a concatenation among the
|
|
490
|
+
* parts is flattened into one.
|
|
491
|
+
*/
|
|
492
|
+
declare function concat(...parts: ConcatPart[]): ConcatOperation;
|
|
493
|
+
/** Text joined end to end. A NULL in any part makes the whole NULL, as with SQL's `||`. */
|
|
494
|
+
declare class ConcatOperation extends Operation implements Sortable {
|
|
495
|
+
readonly parts: RelationalOperationElement[];
|
|
496
|
+
readonly displayName?: string | undefined;
|
|
497
|
+
constructor(parts: RelationalOperationElement[], displayName?: string | undefined);
|
|
498
|
+
/** Join more text on the end: `f.first().concat(' ', f.last())`. A concatenation joins into one. */
|
|
499
|
+
concat(...more: ConcatPart[]): ConcatOperation;
|
|
500
|
+
/** Sort by this expression, smallest first. */
|
|
501
|
+
ascending(): SortOperation;
|
|
502
|
+
/** Sort by this expression, largest first. */
|
|
503
|
+
descending(): SortOperation;
|
|
504
|
+
comparisonOperand(): RelationalOperationElement;
|
|
505
|
+
}
|
|
506
|
+
interface ConcatOperation extends Comparable, StringPredicates {
|
|
507
|
+
}
|
|
508
|
+
/** The first day of the week, month, quarter or year that the date falls in, as a date. */
|
|
509
|
+
declare class DateTruncOperation extends UnaryOperation implements Sortable {
|
|
510
|
+
readonly part: DatePart;
|
|
511
|
+
readonly displayName?: string | undefined;
|
|
512
|
+
constructor(element: RelationalOperationElement, part: DatePart, displayName?: string | undefined);
|
|
513
|
+
/** Sort by this expression, earliest first. */
|
|
514
|
+
ascending(): SortOperation;
|
|
515
|
+
/** Sort by this expression, latest first. */
|
|
516
|
+
descending(): SortOperation;
|
|
517
|
+
comparisonOperand(): RelationalOperationElement;
|
|
518
|
+
}
|
|
519
|
+
interface DateTruncOperation extends Comparable {
|
|
520
|
+
}
|
|
521
|
+
declare class AggregateOperation extends UnaryOperation implements Sortable {
|
|
522
|
+
readonly operator: AggregateOperator;
|
|
523
|
+
readonly displayName?: string | undefined;
|
|
524
|
+
readonly window?: WindowSpecification | undefined;
|
|
525
|
+
/** For STRING_AGG: what goes between the values. */
|
|
526
|
+
readonly separator?: string | undefined;
|
|
527
|
+
/** For STRING_AGG: the order the values are joined in. */
|
|
528
|
+
readonly orderBy: SortOperation[];
|
|
529
|
+
/** Sort by this expression, smallest first. */
|
|
530
|
+
ascending(): SortOperation;
|
|
531
|
+
/** Sort by this expression, largest first. */
|
|
532
|
+
descending(): SortOperation;
|
|
533
|
+
constructor(element: RelationalOperationElement, operator: AggregateOperator, displayName?: string | undefined, window?: WindowSpecification | undefined,
|
|
534
|
+
/** For STRING_AGG: what goes between the values. */
|
|
535
|
+
separator?: string | undefined,
|
|
536
|
+
/** For STRING_AGG: the order the values are joined in. */
|
|
537
|
+
orderBy?: SortOperation[]);
|
|
538
|
+
arithmeticOperand(): RelationalOperationElement;
|
|
539
|
+
comparisonOperand(): RelationalOperationElement;
|
|
540
|
+
over(partitionBy?: RelationalOperationElement[], orderBy?: SortOperation[]): AggregateOperation;
|
|
541
|
+
}
|
|
542
|
+
interface AggregateOperation extends Arithmetic, Comparable, StringPredicates {
|
|
240
543
|
}
|
|
241
|
-
declare class CountAllOperation extends RelationalOperationElement {
|
|
544
|
+
declare class CountAllOperation extends RelationalOperationElement implements Aliasable, Sortable {
|
|
242
545
|
readonly table: string;
|
|
546
|
+
/** Name this column in the result. */
|
|
547
|
+
alias(name: string): Alias;
|
|
548
|
+
/** Sort by this expression, smallest first. */
|
|
549
|
+
ascending(): SortOperation;
|
|
550
|
+
/** Sort by this expression, largest first. */
|
|
551
|
+
descending(): SortOperation;
|
|
243
552
|
constructor(table: string);
|
|
553
|
+
comparisonOperand(): RelationalOperationElement;
|
|
554
|
+
}
|
|
555
|
+
interface CountAllOperation extends Comparable {
|
|
556
|
+
}
|
|
557
|
+
/** A constant that is a number, so it can be an operand of arithmetic: `constant(100).minus(f.price())`. */
|
|
558
|
+
declare abstract class NumericConstantOperation extends ConstantOperation {
|
|
559
|
+
abstract readonly value: number;
|
|
560
|
+
arithmeticOperand(): RelationalOperationElement;
|
|
561
|
+
}
|
|
562
|
+
interface NumericConstantOperation extends Arithmetic {
|
|
563
|
+
}
|
|
564
|
+
declare abstract class ConstantOperation extends RelationalOperationElement implements Aliasable, Sortable {
|
|
565
|
+
/** Name this column in the result. */
|
|
566
|
+
alias(name: string): Alias;
|
|
567
|
+
/** Sort by this expression, smallest first. */
|
|
568
|
+
ascending(): SortOperation;
|
|
569
|
+
/** Sort by this expression, largest first. */
|
|
570
|
+
descending(): SortOperation;
|
|
571
|
+
}
|
|
572
|
+
interface ConstantOperation extends Aggregates {
|
|
573
|
+
}
|
|
574
|
+
/** `left operator right` on numbers, e.g. `price * quantity`. */
|
|
575
|
+
declare class ArithmeticOperation extends BinaryOperation implements Sortable {
|
|
576
|
+
readonly operator: ArithmeticOperator;
|
|
577
|
+
readonly displayName?: string | undefined;
|
|
578
|
+
constructor(left: RelationalOperationElement, operator: ArithmeticOperator, right: RelationalOperationElement, displayName?: string | undefined);
|
|
579
|
+
/** Sort by this expression, smallest first. */
|
|
580
|
+
ascending(): SortOperation;
|
|
581
|
+
/** Sort by this expression, largest first. */
|
|
582
|
+
descending(): SortOperation;
|
|
583
|
+
arithmeticOperand(): RelationalOperationElement;
|
|
584
|
+
comparisonOperand(): RelationalOperationElement;
|
|
585
|
+
}
|
|
586
|
+
interface ArithmeticOperation extends Arithmetic, Comparable {
|
|
587
|
+
}
|
|
588
|
+
interface ArithmeticOperation extends Aggregates {
|
|
589
|
+
}
|
|
590
|
+
declare class ScalarFunctionOperation extends UnaryOperation implements Sortable {
|
|
591
|
+
readonly func: ScalarFunction;
|
|
592
|
+
readonly displayName?: string | undefined;
|
|
593
|
+
readonly secondArg?: number | undefined;
|
|
594
|
+
readonly extraArgs: (string | number | boolean)[];
|
|
595
|
+
/** Sort by this expression, smallest first. */
|
|
596
|
+
ascending(): SortOperation;
|
|
597
|
+
/** Sort by this expression, largest first. */
|
|
598
|
+
descending(): SortOperation;
|
|
599
|
+
constructor(element: RelationalOperationElement, func: ScalarFunction, displayName?: string | undefined, secondArg?: number | undefined, extraArgs?: (string | number | boolean)[]);
|
|
600
|
+
/** This expression as an operand of a comparison. */
|
|
601
|
+
comparisonOperand(): RelationalOperationElement;
|
|
602
|
+
arithmeticOperand(): RelationalOperationElement;
|
|
603
|
+
/** Only a function that gives a number can be used in arithmetic. */
|
|
604
|
+
assertNumeric(): void;
|
|
605
|
+
}
|
|
606
|
+
interface ScalarFunctionOperation extends Comparable, Arithmetic, StringPredicates {
|
|
607
|
+
}
|
|
608
|
+
interface ScalarFunctionOperation extends Aggregates {
|
|
609
|
+
}
|
|
610
|
+
/** `CASE WHEN condition THEN then ELSE fallback END`; without a `fallback` the value is NULL. */
|
|
611
|
+
declare class CaseOperation extends Operation {
|
|
612
|
+
readonly condition: RelationalOperationElement;
|
|
613
|
+
readonly then: RelationalOperationElement;
|
|
614
|
+
readonly fallback?: RelationalOperationElement | undefined;
|
|
615
|
+
readonly displayName?: string | undefined;
|
|
616
|
+
constructor(condition: RelationalOperationElement, then: RelationalOperationElement, fallback?: RelationalOperationElement | undefined, displayName?: string | undefined);
|
|
617
|
+
}
|
|
618
|
+
interface CaseOperation extends Aggregates {
|
|
619
|
+
}
|
|
620
|
+
declare class IsNullOperation extends UnaryOperation {
|
|
621
|
+
}
|
|
622
|
+
interface IsNullOperation extends BooleanAggregates {
|
|
623
|
+
}
|
|
624
|
+
declare class IsNotNullOperation extends UnaryOperation {
|
|
625
|
+
}
|
|
626
|
+
interface IsNotNullOperation extends BooleanAggregates {
|
|
627
|
+
}
|
|
628
|
+
/** The element is one of `values` (`element IN (...)`). */
|
|
629
|
+
declare class InOperation extends UnaryOperation {
|
|
630
|
+
readonly values: ConstantOperation[];
|
|
631
|
+
constructor(element: RelationalOperationElement, values: ConstantOperation[]);
|
|
632
|
+
}
|
|
633
|
+
interface InOperation extends BooleanAggregates {
|
|
634
|
+
}
|
|
635
|
+
/** The element is none of `values` (`element NOT IN (...)`). */
|
|
636
|
+
declare class NotInOperation extends UnaryOperation {
|
|
637
|
+
readonly values: ConstantOperation[];
|
|
638
|
+
constructor(element: RelationalOperationElement, values: ConstantOperation[]);
|
|
639
|
+
}
|
|
640
|
+
interface NotInOperation extends BooleanAggregates {
|
|
641
|
+
}
|
|
642
|
+
declare class ComparisonOperation extends BinaryOperation {
|
|
643
|
+
readonly operator: ComparisonOperator;
|
|
644
|
+
constructor(left: RelationalOperationElement, operator: ComparisonOperator, right: RelationalOperationElement);
|
|
645
|
+
}
|
|
646
|
+
interface ComparisonOperation extends BooleanAggregates {
|
|
647
|
+
}
|
|
648
|
+
declare class LogicalOperation extends BinaryOperation {
|
|
649
|
+
readonly operator: LogicalOperator;
|
|
650
|
+
constructor(left: RelationalOperationElement, operator: LogicalOperator, right: RelationalOperationElement);
|
|
651
|
+
}
|
|
652
|
+
interface LogicalOperation extends BooleanAggregates {
|
|
244
653
|
}
|
|
245
654
|
|
|
246
|
-
export { AggregateOperation, AggregateOperator, BinaryOperation, BooleanConstantOperation, Column, ColumnWithJoin, ComparisonOperation, ComparisonOperator, ConstantOperation, CountAllOperation, DataCatalog, DataStore, Database, DateArithmeticOperation, DateConstantOperation, DateDiffOperation, DateExtractOperation, DatePart, DateTimeConstantOperation, DecimalConstantOperation, FloatConstantOperation, ForeignKey, IntegerConstantOperation, IsNotNullOperation, IsNullOperation, JoinOperation, JoinTreeNodeOperation, LogicalOperation, LogicalOperator, NoOperation, Operation, RelationalOperationElement, ScalarFunction, ScalarFunctionOperation, Schema, SortDirection, SortOperation, StringConstantOperation, Table, UnaryOperation, WindowFunction, WindowFunctionOperation, WindowSpecification };
|
|
655
|
+
export { AggregateOperation, AggregateOperator, Aggregates, Alias, type Aliasable, Arithmetic, type ArithmeticOperand, ArithmeticOperation, ArithmeticOperator, BinaryOperation, BooleanAggregates, BooleanConstantOperation, CaseOperation, Column, ColumnWithJoin, Comparable, ComparisonOperation, ComparisonOperator, ConcatOperation, type ConcatPart, ConstantOperation, CountAllOperation, DATE_ONLY_PATTERN, DataCatalog, DataStore, Database, DateArithmeticOperation, DateConstantOperation, DateDiffOperation, DateExtractOperation, DateOnly, DatePart, DateTimeConstantOperation, DateTruncOperation, DecimalConstantOperation, ExistsOperation, FloatConstantOperation, ForeignKey, InOperation, IntegerConstantOperation, IsNotNullOperation, IsNullOperation, JoinOperation, JoinTreeNodeOperation, LIKE_ESCAPE, LogicalOperation, LogicalOperator, NUMERIC_FUNCTIONS, NoOperation, NotExistsOperation, NotInOperation, NumericConstantOperation, Operation, RelationalOperationElement, ScalarFunction, ScalarFunctionOperation, Schema, SelectOperation, SortDirection, SortOperation, type Sortable, StringConstantOperation, StringPredicates, Table, UnaryOperation, WindowFunction, WindowFunctionOperation, WindowSpecification, applyMixins, concat, containsAggregate, containsAggregateOrWindow, escapeLike, operandOf, sample, valueOperand };
|