@ahoo-wang/wow-client 9.7.0 → 9.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/decorate.es.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/decorateMetadata.es.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/decorateParam.es.js +1 -1
- package/dist/client/command/commandClient.cjs +1 -1
- package/dist/client/command/commandClient.es.js +3 -3
- package/dist/client/metadata/wowMetadataClient.cjs +1 -1
- package/dist/client/metadata/wowMetadataClient.es.js +3 -3
- package/dist/client/query/dataset/datasetDescriptorEndpoint.cjs +2 -0
- package/dist/client/query/dataset/datasetDescriptorEndpoint.cjs.map +1 -0
- package/dist/client/query/dataset/datasetDescriptorEndpoint.d.cts +8 -0
- package/dist/client/query/dataset/datasetDescriptorEndpoint.d.ts +8 -0
- package/dist/client/query/dataset/datasetDescriptorEndpoint.es.js +34 -0
- package/dist/client/query/dataset/datasetDescriptorEndpoint.es.js.map +1 -0
- package/dist/client/query/dataset/datasetDirectoryClient.cjs +2 -0
- package/dist/client/query/dataset/datasetDirectoryClient.cjs.map +1 -0
- package/dist/client/query/dataset/datasetDirectoryClient.d.cts +29 -0
- package/dist/client/query/dataset/datasetDirectoryClient.d.ts +29 -0
- package/dist/client/query/dataset/datasetDirectoryClient.es.js +25 -0
- package/dist/client/query/dataset/datasetDirectoryClient.es.js.map +1 -0
- package/dist/client/query/dataset/datasetQueryApi.d.cts +40 -0
- package/dist/client/query/dataset/datasetQueryApi.d.ts +40 -0
- package/dist/client/query/dataset/datasetQueryClient.cjs +2 -0
- package/dist/client/query/dataset/datasetQueryClient.cjs.map +1 -0
- package/dist/client/query/dataset/datasetQueryClient.d.cts +57 -0
- package/dist/client/query/dataset/datasetQueryClient.d.ts +57 -0
- package/dist/client/query/dataset/datasetQueryClient.es.js +154 -0
- package/dist/client/query/dataset/datasetQueryClient.es.js.map +1 -0
- package/dist/client/query/dataset/endpointPaths.cjs +2 -0
- package/dist/client/query/dataset/endpointPaths.cjs.map +1 -0
- package/dist/client/query/dataset/endpointPaths.d.cts +9 -0
- package/dist/client/query/dataset/endpointPaths.d.ts +9 -0
- package/dist/client/query/dataset/endpointPaths.es.js +14 -0
- package/dist/client/query/dataset/endpointPaths.es.js.map +1 -0
- package/dist/client/query/dataset/index.d.cts +3 -0
- package/dist/client/query/dataset/index.d.ts +3 -0
- package/dist/client/query/descriptor/descriptorEndpoints.cjs +1 -1
- package/dist/client/query/descriptor/descriptorEndpoints.es.js +3 -3
- package/dist/client/query/event/eventStreamQueryApi.d.cts +1 -1
- package/dist/client/query/event/eventStreamQueryApi.d.ts +1 -1
- package/dist/client/query/event/eventStreamQueryClient.cjs +1 -1
- package/dist/client/query/event/eventStreamQueryClient.cjs.map +1 -1
- package/dist/client/query/event/eventStreamQueryClient.d.cts +4 -1
- package/dist/client/query/event/eventStreamQueryClient.d.ts +4 -1
- package/dist/client/query/event/eventStreamQueryClient.es.js +3 -3
- package/dist/client/query/event/eventStreamQueryClient.es.js.map +1 -1
- package/dist/client/query/event/index.d.cts +0 -1
- package/dist/client/query/event/index.d.ts +0 -1
- package/dist/client/query/index.d.cts +1 -0
- package/dist/client/query/index.d.ts +1 -0
- package/dist/client/query/snapshot/index.d.cts +0 -1
- package/dist/client/query/snapshot/index.d.ts +0 -1
- package/dist/client/query/snapshot/snapshotQueryApi.d.cts +1 -1
- package/dist/client/query/snapshot/snapshotQueryApi.d.ts +1 -1
- package/dist/client/query/snapshot/snapshotQueryClient.cjs +1 -1
- package/dist/client/query/snapshot/snapshotQueryClient.cjs.map +1 -1
- package/dist/client/query/snapshot/snapshotQueryClient.d.cts +4 -1
- package/dist/client/query/snapshot/snapshotQueryClient.d.ts +4 -1
- package/dist/client/query/snapshot/snapshotQueryClient.es.js +3 -3
- package/dist/client/query/snapshot/snapshotQueryClient.es.js.map +1 -1
- package/dist/client/query/state/loadOwnerStateAggregateClient.cjs +1 -1
- package/dist/client/query/state/loadOwnerStateAggregateClient.es.js +3 -3
- package/dist/client/query/state/loadStateAggregateClient.cjs +1 -1
- package/dist/client/query/state/loadStateAggregateClient.es.js +3 -3
- package/dist/client/routing.cjs.map +1 -1
- package/dist/client/routing.d.cts +2 -2
- package/dist/client/routing.d.ts +2 -2
- package/dist/client/routing.es.js.map +1 -1
- package/dist/dsl/aggregation/admit.cjs +1 -1
- package/dist/dsl/aggregation/admit.cjs.map +1 -1
- package/dist/dsl/aggregation/admit.es.js +84 -65
- package/dist/dsl/aggregation/admit.es.js.map +1 -1
- package/dist/dsl/aggregation/builders.cjs +1 -1
- package/dist/dsl/aggregation/builders.cjs.map +1 -1
- package/dist/dsl/aggregation/builders.d.cts +16 -4
- package/dist/dsl/aggregation/builders.d.ts +16 -4
- package/dist/dsl/aggregation/builders.es.js +89 -78
- package/dist/dsl/aggregation/builders.es.js.map +1 -1
- package/dist/dsl/aggregation/derived.cjs +1 -1
- package/dist/dsl/aggregation/derived.cjs.map +1 -1
- package/dist/dsl/aggregation/derived.d.cts +32 -1
- package/dist/dsl/aggregation/derived.d.ts +32 -1
- package/dist/dsl/aggregation/derived.es.js +23 -1
- package/dist/dsl/aggregation/derived.es.js.map +1 -1
- package/dist/dsl/aggregation/types.cjs +1 -1
- package/dist/dsl/aggregation/types.cjs.map +1 -1
- package/dist/dsl/aggregation/types.d.cts +112 -7
- package/dist/dsl/aggregation/types.d.ts +112 -7
- package/dist/dsl/aggregation/types.es.js +19 -12
- package/dist/dsl/aggregation/types.es.js.map +1 -1
- package/dist/dsl/descriptor.cjs +1 -1
- package/dist/dsl/descriptor.cjs.map +1 -1
- package/dist/dsl/descriptor.d.cts +16 -1
- package/dist/dsl/descriptor.d.ts +16 -1
- package/dist/dsl/descriptor.es.js +2 -1
- package/dist/dsl/descriptor.es.js.map +1 -1
- package/dist/dsl/filter/datePattern.cjs +1 -1
- package/dist/dsl/filter/datePattern.cjs.map +1 -1
- package/dist/dsl/filter/datePattern.es.js +2 -5
- package/dist/dsl/filter/datePattern.es.js.map +1 -1
- package/dist/dsl.cjs +1 -1
- package/dist/dsl.d.cts +2 -2
- package/dist/dsl.d.ts +2 -2
- package/dist/dsl.es.js +13 -13
- package/dist/error/headers.cjs.map +1 -1
- package/dist/error/headers.d.cts +3 -2
- package/dist/error/headers.d.ts +3 -2
- package/dist/error/headers.es.js.map +1 -1
- package/dist/error/queryErrorCodes.cjs +1 -1
- package/dist/error/queryErrorCodes.cjs.map +1 -1
- package/dist/error/queryErrorCodes.d.cts +7 -0
- package/dist/error/queryErrorCodes.d.ts +7 -0
- package/dist/error/queryErrorCodes.es.js +2 -1
- package/dist/error/queryErrorCodes.es.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.es.js +35 -33
- package/dist/model/domainEventStream.cjs.map +1 -0
- package/dist/{client/query/event → model}/domainEventStream.d.cts +5 -1
- package/dist/{client/query/event → model}/domainEventStream.d.ts +5 -1
- package/dist/{client/query/event → model}/domainEventStream.es.js +1 -1
- package/dist/model/domainEventStream.es.js.map +1 -0
- package/dist/model/index.d.cts +2 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/snapshot.cjs.map +1 -0
- package/dist/{client/query/snapshot → model}/snapshot.d.cts +3 -1
- package/dist/{client/query/snapshot → model}/snapshot.d.ts +3 -1
- package/dist/{client/query/snapshot → model}/snapshot.es.js +1 -1
- package/dist/model/snapshot.es.js.map +1 -0
- package/dist/transport/eventStreams.cjs +1 -1
- package/dist/transport/eventStreams.cjs.map +1 -1
- package/dist/transport/eventStreams.d.cts +3 -1
- package/dist/transport/eventStreams.d.ts +3 -1
- package/dist/transport/eventStreams.es.js +7 -8
- package/dist/transport/eventStreams.es.js.map +1 -1
- package/package.json +3 -3
- package/dist/client/query/event/domainEventStream.cjs.map +0 -1
- package/dist/client/query/event/domainEventStream.es.js.map +0 -1
- package/dist/client/query/snapshot/snapshot.cjs.map +0 -1
- package/dist/client/query/snapshot/snapshot.es.js.map +0 -1
- /package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/decorate.cjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/decorateMetadata.cjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/decorateParam.cjs +0 -0
- /package/dist/{client/query/event → model}/domainEventStream.cjs +0 -0
- /package/dist/{client/query/snapshot → model}/snapshot.cjs +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ElementFilterExpression, FilterExpression, QueryField, ExpressionFilter } from '../filter/index.cjs';
|
|
2
|
-
import { FieldSort } from '../sort.cjs';
|
|
2
|
+
import { FieldSort, SortDirection } from '../sort.cjs';
|
|
3
3
|
/** The kind of an {@link AggregationGroup}, sent as its `type`. */
|
|
4
4
|
export declare enum AggregationGroupType {
|
|
5
5
|
/** One group per distinct value; {@link aggregation.terms}. */
|
|
@@ -14,6 +14,16 @@ export declare enum AggregationGroupType {
|
|
|
14
14
|
*/
|
|
15
15
|
DATE_PART = "DATE_PART"
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* What an {@link AggregationGroup}'s field is relative to when the query
|
|
19
|
+
* expands elements, sent as its `scope`. Wow 9.9 and later.
|
|
20
|
+
*/
|
|
21
|
+
export declare enum AggregationGroupScope {
|
|
22
|
+
/** The innermost expanded element; the default. */
|
|
23
|
+
ELEMENT = "ELEMENT",
|
|
24
|
+
/** The root record, so the elements are grouped by a field of their root. */
|
|
25
|
+
ROOT = "ROOT"
|
|
26
|
+
}
|
|
17
27
|
/**
|
|
18
28
|
* The kind of an {@link AggregationMetric}, sent as its `type`. Wow 8.12
|
|
19
29
|
* knows `COUNT` and `NUMERIC`, Wow 9.0 adds `ANY`, and the other three need
|
|
@@ -164,6 +174,13 @@ interface AggregationGroupBase<FIELDS extends string = string> {
|
|
|
164
174
|
field: QueryField<FIELDS>;
|
|
165
175
|
/** The name of the group's column in the result rows. */
|
|
166
176
|
alias: string;
|
|
177
|
+
/**
|
|
178
|
+
* What `field` is relative to when the query expands elements: the
|
|
179
|
+
* innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
|
|
180
|
+
* A `ROOT` group names a field, never an expression. Wow 9.9 and later,
|
|
181
|
+
* where `analysis.rootGroups` is `true`.
|
|
182
|
+
*/
|
|
183
|
+
scope?: AggregationGroupScope;
|
|
167
184
|
}
|
|
168
185
|
/**
|
|
169
186
|
* What a TERMS or HISTOGRAM group groups by: a field, or a computed
|
|
@@ -190,6 +207,13 @@ export type TermsAggregationGroup<FIELDS extends string = string> = {
|
|
|
190
207
|
alias: string;
|
|
191
208
|
/** The key the rows without a value are grouped under. Wow 9.1 and later. */
|
|
192
209
|
missingKey?: string;
|
|
210
|
+
/**
|
|
211
|
+
* What `field` is relative to when the query expands elements: the
|
|
212
|
+
* innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
|
|
213
|
+
* A `ROOT` group names a field, never an expression. Wow 9.9 and later,
|
|
214
|
+
* where `analysis.rootGroups` is `true`.
|
|
215
|
+
*/
|
|
216
|
+
scope?: AggregationGroupScope;
|
|
193
217
|
} & AggregationGroupInput<FIELDS>;
|
|
194
218
|
/**
|
|
195
219
|
* Buckets of equal width over a number field, or over an expression;
|
|
@@ -201,6 +225,13 @@ export type HistogramAggregationGroup<FIELDS extends string = string> = {
|
|
|
201
225
|
alias: string;
|
|
202
226
|
/** The width of each bucket, greater than 0. */
|
|
203
227
|
interval: number;
|
|
228
|
+
/**
|
|
229
|
+
* What `field` is relative to when the query expands elements: the
|
|
230
|
+
* innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
|
|
231
|
+
* A `ROOT` group names a field, never an expression. Wow 9.9 and later,
|
|
232
|
+
* where `analysis.rootGroups` is `true`.
|
|
233
|
+
*/
|
|
234
|
+
scope?: AggregationGroupScope;
|
|
204
235
|
} & AggregationGroupInput<FIELDS>;
|
|
205
236
|
/**
|
|
206
237
|
* Calendar buckets over a time field in epoch milliseconds;
|
|
@@ -390,8 +421,71 @@ export declare enum DerivedExpressionType {
|
|
|
390
421
|
/** A number. */
|
|
391
422
|
CONSTANT = "CONSTANT",
|
|
392
423
|
/** Two operands and an {@link AggregationExpressionOperator}. */
|
|
393
|
-
BINARY = "BINARY"
|
|
424
|
+
BINARY = "BINARY",
|
|
425
|
+
/** A window: the metric summed over a partition of the groups. */
|
|
426
|
+
TOTAL = "TOTAL",
|
|
427
|
+
/** A window: the metric accumulated along an order, or its moving average. */
|
|
428
|
+
RUNNING = "RUNNING",
|
|
429
|
+
/** A window: the metric of an earlier period along a date group. */
|
|
430
|
+
PREVIOUS = "PREVIOUS",
|
|
431
|
+
/** A window: the dense rank of the metric within a partition. */
|
|
432
|
+
RANK = "RANK"
|
|
394
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* The window functions of derived expressions, as a storage declares them in
|
|
436
|
+
* `analysis.windows` of its descriptor.
|
|
437
|
+
*/
|
|
438
|
+
export declare enum WindowFunction {
|
|
439
|
+
TOTAL = "TOTAL",
|
|
440
|
+
RUNNING = "RUNNING",
|
|
441
|
+
PREVIOUS = "PREVIOUS",
|
|
442
|
+
RANK = "RANK"
|
|
443
|
+
}
|
|
444
|
+
/** What a `RUNNING` window computes over its frame. */
|
|
445
|
+
export declare enum RunningFunction {
|
|
446
|
+
SUM = "SUM",
|
|
447
|
+
AVG = "AVG"
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* A window over the groups of the aggregation. Wow computes it over every
|
|
451
|
+
* group the filter selects, before `having`, `sort` and `limit`; `metric`
|
|
452
|
+
* names a non-derived numeric metric declared before the derived one, and
|
|
453
|
+
* `within`, `order` and `along` name groups of the query. Wow 9.9 and later,
|
|
454
|
+
* where `analysis.windows` lists the function.
|
|
455
|
+
*/
|
|
456
|
+
export type DerivedWindow = {
|
|
457
|
+
type: DerivedExpressionType.TOTAL;
|
|
458
|
+
/** A `COUNT` or `SUM` metric. */
|
|
459
|
+
metric: string;
|
|
460
|
+
/** The partition's group aliases; every group when absent. */
|
|
461
|
+
within?: string[];
|
|
462
|
+
} | {
|
|
463
|
+
type: DerivedExpressionType.RUNNING;
|
|
464
|
+
/** A `COUNT` or `SUM` metric for `SUM`; any numeric metric for `AVG`. */
|
|
465
|
+
metric: string;
|
|
466
|
+
/** A group alias or a non-derived numeric metric, with its direction. */
|
|
467
|
+
order: FieldSort;
|
|
468
|
+
within?: string[];
|
|
469
|
+
/** The last this many groups; every group up to this one when absent. */
|
|
470
|
+
frame?: number;
|
|
471
|
+
/** `SUM` when absent. */
|
|
472
|
+
function?: RunningFunction;
|
|
473
|
+
} | {
|
|
474
|
+
type: DerivedExpressionType.PREVIOUS;
|
|
475
|
+
metric: string;
|
|
476
|
+
/** The alias of a `DATE_HISTOGRAM` group. */
|
|
477
|
+
along: string;
|
|
478
|
+
/** How many steps back; 1 when absent. */
|
|
479
|
+
shift?: number;
|
|
480
|
+
/** Step by this calendar period instead of by one bucket of `along`. */
|
|
481
|
+
period?: AggregationDateUnit;
|
|
482
|
+
} | {
|
|
483
|
+
type: DerivedExpressionType.RANK;
|
|
484
|
+
metric: string;
|
|
485
|
+
within?: string[];
|
|
486
|
+
/** `DESC` when absent. */
|
|
487
|
+
direction?: SortDirection;
|
|
488
|
+
};
|
|
395
489
|
/**
|
|
396
490
|
* Post-aggregation arithmetic; references must name earlier metrics that are
|
|
397
491
|
* not `ANY`, `FIRST` or `LAST`.
|
|
@@ -407,7 +501,7 @@ export type DerivedExpression = {
|
|
|
407
501
|
operator: AggregationExpressionOperator;
|
|
408
502
|
left: DerivedExpression;
|
|
409
503
|
right: DerivedExpression;
|
|
410
|
-
};
|
|
504
|
+
} | DerivedWindow;
|
|
411
505
|
/**
|
|
412
506
|
* A metric computed from metrics declared before it in the same query, after
|
|
413
507
|
* aggregation; {@link aggregation.derived}. Wow 9.1 and later.
|
|
@@ -533,18 +627,27 @@ export interface AggregationMetricOptions<FIELDS extends string = string> {
|
|
|
533
627
|
/** Counts only the rows that match; sent as the metric's `filter`. */
|
|
534
628
|
filter?: FilterExpression<FIELDS>;
|
|
535
629
|
}
|
|
630
|
+
/** The option every group builder takes. */
|
|
631
|
+
export interface AggregationGroupScopeOptions {
|
|
632
|
+
/**
|
|
633
|
+
* What the field is relative to when the query expands elements; the
|
|
634
|
+
* innermost element when absent. `ROOT` needs a field input. Wow 9.9 and
|
|
635
|
+
* later.
|
|
636
|
+
*/
|
|
637
|
+
scope?: AggregationGroupScope;
|
|
638
|
+
}
|
|
536
639
|
/** The options of {@link aggregation.terms}. */
|
|
537
|
-
export interface TermsAggregationOptions {
|
|
640
|
+
export interface TermsAggregationOptions extends AggregationGroupScopeOptions {
|
|
538
641
|
/** The key rows without a value are grouped under; must not be blank. */
|
|
539
642
|
missingKey?: string;
|
|
540
643
|
}
|
|
541
644
|
/** The options of {@link aggregation.histogram}. */
|
|
542
|
-
export interface HistogramAggregationOptions {
|
|
645
|
+
export interface HistogramAggregationOptions extends AggregationGroupScopeOptions {
|
|
543
646
|
/** The width of each bucket: finite and greater than 0. */
|
|
544
647
|
interval: number;
|
|
545
648
|
}
|
|
546
649
|
/** The options of {@link aggregation.dateHistogram}. */
|
|
547
|
-
export interface DateHistogramAggregationOptions {
|
|
650
|
+
export interface DateHistogramAggregationOptions extends AggregationGroupScopeOptions {
|
|
548
651
|
/** The calendar unit of each bucket. */
|
|
549
652
|
unit: AggregationDateUnit;
|
|
550
653
|
/** The zone the buckets are cut in, an IANA id. Defaults to `UTC`. */
|
|
@@ -556,7 +659,7 @@ export interface DateHistogramAggregationOptions {
|
|
|
556
659
|
dense?: boolean;
|
|
557
660
|
}
|
|
558
661
|
/** The options of {@link aggregation.datePart}. */
|
|
559
|
-
export interface DatePartAggregationOptions {
|
|
662
|
+
export interface DatePartAggregationOptions extends AggregationGroupScopeOptions {
|
|
560
663
|
/** The calendar part each row is grouped by. */
|
|
561
664
|
part: AggregationDatePart;
|
|
562
665
|
/** The zone the part is read in, an IANA id. Defaults to `UTC`. */
|
|
@@ -604,5 +707,7 @@ export declare const AGGREGATION_LIMITS: Readonly<{
|
|
|
604
707
|
MAX_EXPRESSION_DEPTH: 8;
|
|
605
708
|
/** The most expression nodes in the whole query. */
|
|
606
709
|
MAX_EXPRESSION_NODES: 256;
|
|
710
|
+
/** The most windows in the whole query. */
|
|
711
|
+
MAX_WINDOWS: 8;
|
|
607
712
|
}>;
|
|
608
713
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ElementFilterExpression, FilterExpression, QueryField, ExpressionFilter } from '../filter/index.js';
|
|
2
|
-
import { FieldSort } from '../sort.js';
|
|
2
|
+
import { FieldSort, SortDirection } from '../sort.js';
|
|
3
3
|
/** The kind of an {@link AggregationGroup}, sent as its `type`. */
|
|
4
4
|
export declare enum AggregationGroupType {
|
|
5
5
|
/** One group per distinct value; {@link aggregation.terms}. */
|
|
@@ -14,6 +14,16 @@ export declare enum AggregationGroupType {
|
|
|
14
14
|
*/
|
|
15
15
|
DATE_PART = "DATE_PART"
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* What an {@link AggregationGroup}'s field is relative to when the query
|
|
19
|
+
* expands elements, sent as its `scope`. Wow 9.9 and later.
|
|
20
|
+
*/
|
|
21
|
+
export declare enum AggregationGroupScope {
|
|
22
|
+
/** The innermost expanded element; the default. */
|
|
23
|
+
ELEMENT = "ELEMENT",
|
|
24
|
+
/** The root record, so the elements are grouped by a field of their root. */
|
|
25
|
+
ROOT = "ROOT"
|
|
26
|
+
}
|
|
17
27
|
/**
|
|
18
28
|
* The kind of an {@link AggregationMetric}, sent as its `type`. Wow 8.12
|
|
19
29
|
* knows `COUNT` and `NUMERIC`, Wow 9.0 adds `ANY`, and the other three need
|
|
@@ -164,6 +174,13 @@ interface AggregationGroupBase<FIELDS extends string = string> {
|
|
|
164
174
|
field: QueryField<FIELDS>;
|
|
165
175
|
/** The name of the group's column in the result rows. */
|
|
166
176
|
alias: string;
|
|
177
|
+
/**
|
|
178
|
+
* What `field` is relative to when the query expands elements: the
|
|
179
|
+
* innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
|
|
180
|
+
* A `ROOT` group names a field, never an expression. Wow 9.9 and later,
|
|
181
|
+
* where `analysis.rootGroups` is `true`.
|
|
182
|
+
*/
|
|
183
|
+
scope?: AggregationGroupScope;
|
|
167
184
|
}
|
|
168
185
|
/**
|
|
169
186
|
* What a TERMS or HISTOGRAM group groups by: a field, or a computed
|
|
@@ -190,6 +207,13 @@ export type TermsAggregationGroup<FIELDS extends string = string> = {
|
|
|
190
207
|
alias: string;
|
|
191
208
|
/** The key the rows without a value are grouped under. Wow 9.1 and later. */
|
|
192
209
|
missingKey?: string;
|
|
210
|
+
/**
|
|
211
|
+
* What `field` is relative to when the query expands elements: the
|
|
212
|
+
* innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
|
|
213
|
+
* A `ROOT` group names a field, never an expression. Wow 9.9 and later,
|
|
214
|
+
* where `analysis.rootGroups` is `true`.
|
|
215
|
+
*/
|
|
216
|
+
scope?: AggregationGroupScope;
|
|
193
217
|
} & AggregationGroupInput<FIELDS>;
|
|
194
218
|
/**
|
|
195
219
|
* Buckets of equal width over a number field, or over an expression;
|
|
@@ -201,6 +225,13 @@ export type HistogramAggregationGroup<FIELDS extends string = string> = {
|
|
|
201
225
|
alias: string;
|
|
202
226
|
/** The width of each bucket, greater than 0. */
|
|
203
227
|
interval: number;
|
|
228
|
+
/**
|
|
229
|
+
* What `field` is relative to when the query expands elements: the
|
|
230
|
+
* innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
|
|
231
|
+
* A `ROOT` group names a field, never an expression. Wow 9.9 and later,
|
|
232
|
+
* where `analysis.rootGroups` is `true`.
|
|
233
|
+
*/
|
|
234
|
+
scope?: AggregationGroupScope;
|
|
204
235
|
} & AggregationGroupInput<FIELDS>;
|
|
205
236
|
/**
|
|
206
237
|
* Calendar buckets over a time field in epoch milliseconds;
|
|
@@ -390,8 +421,71 @@ export declare enum DerivedExpressionType {
|
|
|
390
421
|
/** A number. */
|
|
391
422
|
CONSTANT = "CONSTANT",
|
|
392
423
|
/** Two operands and an {@link AggregationExpressionOperator}. */
|
|
393
|
-
BINARY = "BINARY"
|
|
424
|
+
BINARY = "BINARY",
|
|
425
|
+
/** A window: the metric summed over a partition of the groups. */
|
|
426
|
+
TOTAL = "TOTAL",
|
|
427
|
+
/** A window: the metric accumulated along an order, or its moving average. */
|
|
428
|
+
RUNNING = "RUNNING",
|
|
429
|
+
/** A window: the metric of an earlier period along a date group. */
|
|
430
|
+
PREVIOUS = "PREVIOUS",
|
|
431
|
+
/** A window: the dense rank of the metric within a partition. */
|
|
432
|
+
RANK = "RANK"
|
|
394
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* The window functions of derived expressions, as a storage declares them in
|
|
436
|
+
* `analysis.windows` of its descriptor.
|
|
437
|
+
*/
|
|
438
|
+
export declare enum WindowFunction {
|
|
439
|
+
TOTAL = "TOTAL",
|
|
440
|
+
RUNNING = "RUNNING",
|
|
441
|
+
PREVIOUS = "PREVIOUS",
|
|
442
|
+
RANK = "RANK"
|
|
443
|
+
}
|
|
444
|
+
/** What a `RUNNING` window computes over its frame. */
|
|
445
|
+
export declare enum RunningFunction {
|
|
446
|
+
SUM = "SUM",
|
|
447
|
+
AVG = "AVG"
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* A window over the groups of the aggregation. Wow computes it over every
|
|
451
|
+
* group the filter selects, before `having`, `sort` and `limit`; `metric`
|
|
452
|
+
* names a non-derived numeric metric declared before the derived one, and
|
|
453
|
+
* `within`, `order` and `along` name groups of the query. Wow 9.9 and later,
|
|
454
|
+
* where `analysis.windows` lists the function.
|
|
455
|
+
*/
|
|
456
|
+
export type DerivedWindow = {
|
|
457
|
+
type: DerivedExpressionType.TOTAL;
|
|
458
|
+
/** A `COUNT` or `SUM` metric. */
|
|
459
|
+
metric: string;
|
|
460
|
+
/** The partition's group aliases; every group when absent. */
|
|
461
|
+
within?: string[];
|
|
462
|
+
} | {
|
|
463
|
+
type: DerivedExpressionType.RUNNING;
|
|
464
|
+
/** A `COUNT` or `SUM` metric for `SUM`; any numeric metric for `AVG`. */
|
|
465
|
+
metric: string;
|
|
466
|
+
/** A group alias or a non-derived numeric metric, with its direction. */
|
|
467
|
+
order: FieldSort;
|
|
468
|
+
within?: string[];
|
|
469
|
+
/** The last this many groups; every group up to this one when absent. */
|
|
470
|
+
frame?: number;
|
|
471
|
+
/** `SUM` when absent. */
|
|
472
|
+
function?: RunningFunction;
|
|
473
|
+
} | {
|
|
474
|
+
type: DerivedExpressionType.PREVIOUS;
|
|
475
|
+
metric: string;
|
|
476
|
+
/** The alias of a `DATE_HISTOGRAM` group. */
|
|
477
|
+
along: string;
|
|
478
|
+
/** How many steps back; 1 when absent. */
|
|
479
|
+
shift?: number;
|
|
480
|
+
/** Step by this calendar period instead of by one bucket of `along`. */
|
|
481
|
+
period?: AggregationDateUnit;
|
|
482
|
+
} | {
|
|
483
|
+
type: DerivedExpressionType.RANK;
|
|
484
|
+
metric: string;
|
|
485
|
+
within?: string[];
|
|
486
|
+
/** `DESC` when absent. */
|
|
487
|
+
direction?: SortDirection;
|
|
488
|
+
};
|
|
395
489
|
/**
|
|
396
490
|
* Post-aggregation arithmetic; references must name earlier metrics that are
|
|
397
491
|
* not `ANY`, `FIRST` or `LAST`.
|
|
@@ -407,7 +501,7 @@ export type DerivedExpression = {
|
|
|
407
501
|
operator: AggregationExpressionOperator;
|
|
408
502
|
left: DerivedExpression;
|
|
409
503
|
right: DerivedExpression;
|
|
410
|
-
};
|
|
504
|
+
} | DerivedWindow;
|
|
411
505
|
/**
|
|
412
506
|
* A metric computed from metrics declared before it in the same query, after
|
|
413
507
|
* aggregation; {@link aggregation.derived}. Wow 9.1 and later.
|
|
@@ -533,18 +627,27 @@ export interface AggregationMetricOptions<FIELDS extends string = string> {
|
|
|
533
627
|
/** Counts only the rows that match; sent as the metric's `filter`. */
|
|
534
628
|
filter?: FilterExpression<FIELDS>;
|
|
535
629
|
}
|
|
630
|
+
/** The option every group builder takes. */
|
|
631
|
+
export interface AggregationGroupScopeOptions {
|
|
632
|
+
/**
|
|
633
|
+
* What the field is relative to when the query expands elements; the
|
|
634
|
+
* innermost element when absent. `ROOT` needs a field input. Wow 9.9 and
|
|
635
|
+
* later.
|
|
636
|
+
*/
|
|
637
|
+
scope?: AggregationGroupScope;
|
|
638
|
+
}
|
|
536
639
|
/** The options of {@link aggregation.terms}. */
|
|
537
|
-
export interface TermsAggregationOptions {
|
|
640
|
+
export interface TermsAggregationOptions extends AggregationGroupScopeOptions {
|
|
538
641
|
/** The key rows without a value are grouped under; must not be blank. */
|
|
539
642
|
missingKey?: string;
|
|
540
643
|
}
|
|
541
644
|
/** The options of {@link aggregation.histogram}. */
|
|
542
|
-
export interface HistogramAggregationOptions {
|
|
645
|
+
export interface HistogramAggregationOptions extends AggregationGroupScopeOptions {
|
|
543
646
|
/** The width of each bucket: finite and greater than 0. */
|
|
544
647
|
interval: number;
|
|
545
648
|
}
|
|
546
649
|
/** The options of {@link aggregation.dateHistogram}. */
|
|
547
|
-
export interface DateHistogramAggregationOptions {
|
|
650
|
+
export interface DateHistogramAggregationOptions extends AggregationGroupScopeOptions {
|
|
548
651
|
/** The calendar unit of each bucket. */
|
|
549
652
|
unit: AggregationDateUnit;
|
|
550
653
|
/** The zone the buckets are cut in, an IANA id. Defaults to `UTC`. */
|
|
@@ -556,7 +659,7 @@ export interface DateHistogramAggregationOptions {
|
|
|
556
659
|
dense?: boolean;
|
|
557
660
|
}
|
|
558
661
|
/** The options of {@link aggregation.datePart}. */
|
|
559
|
-
export interface DatePartAggregationOptions {
|
|
662
|
+
export interface DatePartAggregationOptions extends AggregationGroupScopeOptions {
|
|
560
663
|
/** The calendar part each row is grouped by. */
|
|
561
664
|
part: AggregationDatePart;
|
|
562
665
|
/** The zone the part is read in, an IANA id. Defaults to `UTC`. */
|
|
@@ -604,5 +707,7 @@ export declare const AGGREGATION_LIMITS: Readonly<{
|
|
|
604
707
|
MAX_EXPRESSION_DEPTH: 8;
|
|
605
708
|
/** The most expression nodes in the whole query. */
|
|
606
709
|
MAX_EXPRESSION_NODES: 256;
|
|
710
|
+
/** The most windows in the whole query. */
|
|
711
|
+
MAX_WINDOWS: 8;
|
|
607
712
|
}>;
|
|
608
713
|
export {};
|
|
@@ -2,26 +2,32 @@
|
|
|
2
2
|
var e = /* @__PURE__ */ function(e) {
|
|
3
3
|
return e.TERMS = "TERMS", e.HISTOGRAM = "HISTOGRAM", e.DATE_HISTOGRAM = "DATE_HISTOGRAM", e.DATE_PART = "DATE_PART", e;
|
|
4
4
|
}({}), t = /* @__PURE__ */ function(e) {
|
|
5
|
-
return e.
|
|
5
|
+
return e.ELEMENT = "ELEMENT", e.ROOT = "ROOT", e;
|
|
6
6
|
}({}), n = /* @__PURE__ */ function(e) {
|
|
7
|
-
return e.
|
|
7
|
+
return e.COUNT = "COUNT", e.NUMERIC = "NUMERIC", e.ANY = "ANY", e.DISTINCT_COUNT = "DISTINCT_COUNT", e.PERCENTILE = "PERCENTILE", e.DERIVED = "DERIVED", e.FIRST = "FIRST", e.LAST = "LAST", e;
|
|
8
8
|
}({}), r = /* @__PURE__ */ function(e) {
|
|
9
|
-
return e.
|
|
9
|
+
return e.FIELD = "FIELD", e.CONSTANT = "CONSTANT", e.BINARY = "BINARY", e.DATE_DIFF = "DATE_DIFF", e;
|
|
10
10
|
}({}), i = /* @__PURE__ */ function(e) {
|
|
11
|
-
return e.
|
|
11
|
+
return e.SECOND = "SECOND", e.MINUTE = "MINUTE", e.HOUR = "HOUR", e.DAY = "DAY", e;
|
|
12
12
|
}({}), a = /* @__PURE__ */ function(e) {
|
|
13
|
-
return e.
|
|
13
|
+
return e.ADD = "ADD", e.SUBTRACT = "SUBTRACT", e.MULTIPLY = "MULTIPLY", e.DIVIDE = "DIVIDE", e;
|
|
14
14
|
}({}), o = /* @__PURE__ */ function(e) {
|
|
15
|
-
return e.
|
|
15
|
+
return e.YEAR = "YEAR", e.QUARTER = "QUARTER", e.MONTH = "MONTH", e.WEEK = "WEEK", e.DAY = "DAY", e.HOUR = "HOUR", e.MINUTE = "MINUTE", e.SECOND = "SECOND", e;
|
|
16
16
|
}({}), s = /* @__PURE__ */ function(e) {
|
|
17
|
-
return e.
|
|
17
|
+
return e.DAY_OF_WEEK = "DAY_OF_WEEK", e.DAY_OF_MONTH = "DAY_OF_MONTH", e.HOUR_OF_DAY = "HOUR_OF_DAY", e.MONTH_OF_YEAR = "MONTH_OF_YEAR", e;
|
|
18
18
|
}({}), c = /* @__PURE__ */ function(e) {
|
|
19
|
-
return e.
|
|
19
|
+
return e.SUM = "SUM", e.AVG = "AVG", e.MIN = "MIN", e.MAX = "MAX", e.STDDEV = "STDDEV", e.VARIANCE = "VARIANCE", e;
|
|
20
20
|
}({}), l = /* @__PURE__ */ function(e) {
|
|
21
|
-
return e.
|
|
21
|
+
return e.METRIC_REF = "METRIC_REF", e.CONSTANT = "CONSTANT", e.BINARY = "BINARY", e.TOTAL = "TOTAL", e.RUNNING = "RUNNING", e.PREVIOUS = "PREVIOUS", e.RANK = "RANK", e;
|
|
22
22
|
}({}), u = /* @__PURE__ */ function(e) {
|
|
23
|
+
return e.TOTAL = "TOTAL", e.RUNNING = "RUNNING", e.PREVIOUS = "PREVIOUS", e.RANK = "RANK", e;
|
|
24
|
+
}({}), d = /* @__PURE__ */ function(e) {
|
|
25
|
+
return e.SUM = "SUM", e.AVG = "AVG", e;
|
|
26
|
+
}({}), f = /* @__PURE__ */ function(e) {
|
|
27
|
+
return e.CONDITION = "CONDITION", e.BETWEEN = "BETWEEN", e.IN = "IN", e.IS_NULL = "IS_NULL", e.AND = "AND", e.OR = "OR", e;
|
|
28
|
+
}({}), p = /* @__PURE__ */ function(e) {
|
|
23
29
|
return e.EQ = "EQ", e.NE = "NE", e.GT = "GT", e.GTE = "GTE", e.LT = "LT", e.LTE = "LTE", e;
|
|
24
|
-
}({}),
|
|
30
|
+
}({}), m = Object.freeze({
|
|
25
31
|
DEFAULT_LIMIT: 100,
|
|
26
32
|
MAX_LIMIT: 1e4,
|
|
27
33
|
MAX_ELEMENTS: 5,
|
|
@@ -29,9 +35,10 @@ var e = /* @__PURE__ */ function(e) {
|
|
|
29
35
|
MAX_METRICS: 64,
|
|
30
36
|
MAX_SORT_FIELDS: 32,
|
|
31
37
|
MAX_EXPRESSION_DEPTH: 8,
|
|
32
|
-
MAX_EXPRESSION_NODES: 256
|
|
38
|
+
MAX_EXPRESSION_NODES: 256,
|
|
39
|
+
MAX_WINDOWS: 8
|
|
33
40
|
});
|
|
34
41
|
//#endregion
|
|
35
|
-
export {
|
|
42
|
+
export { m as AGGREGATION_LIMITS, s as AggregationDatePart, o as AggregationDateUnit, a as AggregationExpressionOperator, r as AggregationExpressionType, c as AggregationFunction, t as AggregationGroupScope, e as AggregationGroupType, n as AggregationMetricType, p as ComparisonOperator, i as DateDiffUnit, l as DerivedExpressionType, f as HavingExpressionType, d as RunningFunction, u as WindowFunction };
|
|
36
43
|
|
|
37
44
|
//# sourceMappingURL=types.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.es.js","names":["AggregationGroupType","\"TERMS\"","\"HISTOGRAM\"","\"DATE_HISTOGRAM\"","\"DATE_PART\"","AggregationMetricType","\"COUNT\"","\"NUMERIC\"","\"ANY\"","\"DISTINCT_COUNT\"","\"PERCENTILE\"","\"DERIVED\"","\"FIRST\"","\"LAST\"","AggregationExpressionType","\"FIELD\"","\"CONSTANT\"","\"BINARY\"","\"DATE_DIFF\"","DateDiffUnit","\"SECOND\"","\"MINUTE\"","\"HOUR\"","\"DAY\"","AggregationExpressionOperator","\"ADD\"","\"SUBTRACT\"","\"MULTIPLY\"","\"DIVIDE\"","AggregationDateUnit","\"YEAR\"","\"QUARTER\"","\"MONTH\"","\"WEEK\"","AggregationDatePart","\"DAY_OF_WEEK\"","\"DAY_OF_MONTH\"","\"HOUR_OF_DAY\"","\"MONTH_OF_YEAR\"","AggregationFunction","\"SUM\"","\"AVG\"","\"MIN\"","\"MAX\"","\"STDDEV\"","\"VARIANCE\"","DerivedExpressionType","\"METRIC_REF\"","HavingExpressionType","\"CONDITION\"","\"BETWEEN\"","\"IN\"","\"IS_NULL\"","\"AND\"","\"OR\"","ComparisonOperator","\"EQ\"","\"NE\"","\"GT\"","\"GTE\"","\"LT\"","\"LTE\"","AGGREGATION_LIMITS"],"sources":["../../../src/dsl/aggregation/types.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ElementFilterExpression,\n FilterExpression,\n QueryField,\n ExpressionFilter,\n} from '../filter/index.js';\nimport type { FieldSort } from '../sort.js';\n\n/** The kind of an {@link AggregationGroup}, sent as its `type`. */\nexport enum AggregationGroupType {\n /** One group per distinct value; {@link aggregation.terms}. */\n TERMS = 'TERMS',\n /** Number buckets of equal width; {@link aggregation.histogram}. */\n HISTOGRAM = 'HISTOGRAM',\n /** Calendar buckets of a time field; {@link aggregation.dateHistogram}. */\n DATE_HISTOGRAM = 'DATE_HISTOGRAM',\n /**\n * One calendar part of a time field, such as the weekday or the hour;\n * {@link aggregation.datePart}. Wow 9.2 and later.\n */\n DATE_PART = 'DATE_PART',\n}\n\n/**\n * The kind of an {@link AggregationMetric}, sent as its `type`. Wow 8.12\n * knows `COUNT` and `NUMERIC`, Wow 9.0 adds `ANY`, and the other three need\n * Wow 9.1.\n */\nexport enum AggregationMetricType {\n /** The number of rows; {@link aggregation.count}. */\n COUNT = 'COUNT',\n /**\n * An {@link AggregationFunction} of an expression; {@link aggregation.sum}\n * and its siblings.\n */\n NUMERIC = 'NUMERIC',\n /** Any one value of a field; {@link aggregation.any}. Wow 9.0 and later. */\n ANY = 'ANY',\n /**\n * The number of distinct values; {@link aggregation.distinctCount}. Wow 9.1\n * and later.\n */\n DISTINCT_COUNT = 'DISTINCT_COUNT',\n /**\n * A percentile of an expression; {@link aggregation.percentile}. Wow 9.1\n * and later.\n */\n PERCENTILE = 'PERCENTILE',\n /**\n * Arithmetic over other metrics; {@link aggregation.derived}. Wow 9.1 and\n * later.\n */\n DERIVED = 'DERIVED',\n /**\n * A field's value on the group's earliest record; {@link aggregation.first}.\n * Wow 9.2 and later.\n */\n FIRST = 'FIRST',\n /**\n * A field's value on the group's latest record; {@link aggregation.last}.\n * Wow 9.2 and later.\n */\n LAST = 'LAST',\n}\n\n/** The kind of an {@link AggregationExpression} node, sent as its `type`. */\nexport enum AggregationExpressionType {\n /** The value of a field; {@link aggregation.field}. */\n FIELD = 'FIELD',\n /** A number; {@link aggregation.constant}. */\n CONSTANT = 'CONSTANT',\n /** Two operands and an {@link AggregationExpressionOperator}. */\n BINARY = 'BINARY',\n /**\n * The time elapsed between two time fields; {@link aggregation.dateDiff}.\n * Wow 9.2 and later.\n */\n DATE_DIFF = 'DATE_DIFF',\n}\n\n/**\n * The unit a `DATE_DIFF` measures elapsed time in. Each has a fixed length:\n * a `DAY` is exactly 24 hours, and months and years, whose length depends on\n * a calendar and a time zone, are not offered.\n */\nexport enum DateDiffUnit {\n SECOND = 'SECOND',\n MINUTE = 'MINUTE',\n HOUR = 'HOUR',\n DAY = 'DAY',\n}\n\n/**\n * The arithmetic of a `BINARY` node, in an {@link AggregationExpression} or a\n * {@link DerivedExpression}.\n */\nexport enum AggregationExpressionOperator {\n /** `left + right` */\n ADD = 'ADD',\n /** `left - right` */\n SUBTRACT = 'SUBTRACT',\n /** `left * right` */\n MULTIPLY = 'MULTIPLY',\n /** `left / right` */\n DIVIDE = 'DIVIDE',\n}\n\n/**\n * The calendar unit of a `DATE_HISTOGRAM` bucket, cut in the group's\n * `timeZone`.\n */\nexport enum AggregationDateUnit {\n YEAR = 'YEAR',\n QUARTER = 'QUARTER',\n MONTH = 'MONTH',\n WEEK = 'WEEK',\n DAY = 'DAY',\n HOUR = 'HOUR',\n MINUTE = 'MINUTE',\n SECOND = 'SECOND',\n}\n\n/**\n * The calendar part a `DATE_PART` group takes of each instant, read in the\n * group's `timeZone`. Its keys are integers from a fixed domain, so records\n * from different days, weeks or years fall into one bucket.\n */\nexport enum AggregationDatePart {\n /** The ISO weekday: 1 is Monday, 7 is Sunday. */\n DAY_OF_WEEK = 'DAY_OF_WEEK',\n /**\n * The day of the month, 1 to 31; days 29 to 31 exist only in the months\n * that have them.\n */\n DAY_OF_MONTH = 'DAY_OF_MONTH',\n /** The hour on the wall clock of the group's `timeZone`, 0 to 23. */\n HOUR_OF_DAY = 'HOUR_OF_DAY',\n /** The month of the year, 1 (January) to 12. */\n MONTH_OF_YEAR = 'MONTH_OF_YEAR',\n}\n\n/**\n * What a `NUMERIC` metric computes over its expression; each has a builder,\n * {@link aggregation.sum} through {@link aggregation.variance}.\n */\nexport enum AggregationFunction {\n /** The sum */\n SUM = 'SUM',\n /** The average */\n AVG = 'AVG',\n /** The least value */\n MIN = 'MIN',\n /** The greatest value */\n MAX = 'MAX',\n /** The standard deviation */\n STDDEV = 'STDDEV',\n /** The variance */\n VARIANCE = 'VARIANCE',\n}\n\n/**\n * An array field whose elements the query aggregates over instead of the\n * root documents; build it with {@link aggregation.element}. A query takes at\n * most `AGGREGATION_LIMITS.MAX_ELEMENTS` of them.\n */\nexport interface AggregationElement {\n /** The array field, a query field path. */\n path: QueryField;\n /**\n * Keeps only the elements that match; no root filters and no search, but\n * an `EXPRESSION` filter may compare an element's computed value.\n */\n filter?: ElementFilterExpression | ExpressionFilter;\n}\n\n/** What every {@link AggregationGroup} has. */\ninterface AggregationGroupBase<FIELDS extends string = string> {\n /** The field the rows are grouped by. */\n field: QueryField<FIELDS>;\n /** The name of the group's column in the result rows. */\n alias: string;\n}\n\n/**\n * What a TERMS or HISTOGRAM group groups by: a field, or a computed\n * expression in its place (Wow 9.2 and later), never both. An expression\n * input is an expensive computation the server admits only where\n * `analysis.expressions` is `true`.\n */\nexport type AggregationGroupInput<FIELDS extends string = string> =\n | {\n /** The field the rows are grouped by. */\n field: QueryField<FIELDS>;\n expression?: undefined;\n }\n | {\n field?: undefined;\n /** The per-row value the rows are grouped by, such as a `DATE_DIFF`. */\n expression: AggregationExpression<FIELDS>;\n };\n\n/**\n * One group per distinct value of a field, or of an expression;\n * {@link aggregation.terms}. `missingKey` needs a field.\n */\nexport type TermsAggregationGroup<FIELDS extends string = string> = {\n type: AggregationGroupType.TERMS;\n /** The name of the group's column in the result rows. */\n alias: string;\n /** The key the rows without a value are grouped under. Wow 9.1 and later. */\n missingKey?: string;\n} & AggregationGroupInput<FIELDS>;\n\n/**\n * Buckets of equal width over a number field, or over an expression;\n * {@link aggregation.histogram}.\n */\nexport type HistogramAggregationGroup<FIELDS extends string = string> = {\n type: AggregationGroupType.HISTOGRAM;\n /** The name of the group's column in the result rows. */\n alias: string;\n /** The width of each bucket, greater than 0. */\n interval: number;\n} & AggregationGroupInput<FIELDS>;\n\n/**\n * Calendar buckets over a time field in epoch milliseconds;\n * {@link aggregation.dateHistogram}.\n */\nexport interface DateHistogramAggregationGroup<\n FIELDS extends string = string,\n> extends AggregationGroupBase<FIELDS> {\n type: AggregationGroupType.DATE_HISTOGRAM;\n /** The calendar unit of each bucket. */\n unit: AggregationDateUnit;\n /** The IANA zone the buckets are cut in; `UTC` when absent. */\n timeZone?: string;\n /**\n * Whether the server fills in the empty buckets of the range. Wow 9.1 and\n * later, and only when this is the query's only group.\n */\n dense?: boolean;\n}\n\n/**\n * One calendar part of a time field in epoch milliseconds, such as the\n * weekday or the hour; {@link aggregation.datePart}. Its keys in the result\n * rows are integers from the part's domain, such as 1 (Monday) to 7 (Sunday)\n * for `DAY_OF_WEEK`. Wow 9.2 and later.\n */\nexport interface DatePartAggregationGroup<\n FIELDS extends string = string,\n> extends AggregationGroupBase<FIELDS> {\n type: AggregationGroupType.DATE_PART;\n /** The calendar part each row is grouped by. */\n part: AggregationDatePart;\n /** The IANA zone the part is read in; `UTC` when absent. */\n timeZone?: string;\n /**\n * Whether the server returns every key of the part's domain, filling a\n * key with no records with each metric's empty value. Only when this is\n * the query's only group.\n */\n dense?: boolean;\n}\n\n/**\n * One dimension of an {@link AggregationQuery}'s `groupBy`: each result row\n * is one combination of the groups' keys.\n */\nexport type AggregationGroup<FIELDS extends string = string> =\n | TermsAggregationGroup<FIELDS>\n | HistogramAggregationGroup<FIELDS>\n | DateHistogramAggregationGroup<FIELDS>\n | DatePartAggregationGroup<FIELDS>;\n\n/** The value of a field, as an operand; {@link aggregation.field}. */\nexport interface FieldAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.FIELD;\n /** The field, a query field path. */\n field: QueryField<FIELDS>;\n}\n\n/** A number, as an operand; {@link aggregation.constant}. */\nexport interface ConstantAggregationExpression {\n type: AggregationExpressionType.CONSTANT;\n /** A finite number. */\n value: number;\n}\n\n/**\n * `left operator right`; {@link aggregation.add}, {@link aggregation.subtract},\n * {@link aggregation.multiply}, {@link aggregation.divide}.\n */\nexport interface BinaryAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.BINARY;\n /** The arithmetic. */\n operator: AggregationExpressionOperator;\n /** The left operand. */\n left: AggregationExpression<FIELDS>;\n /** The right operand. */\n right: AggregationExpression<FIELDS>;\n}\n\n/**\n * The time from the instant in `from` to the instant in `to`, `to − from`,\n * in `unit`, as a signed decimal: negative when `to` is earlier, and no\n * value when either is absent. Both are single-valued time fields (their\n * `aggregate.groups` list `DATE_HISTOGRAM`), each read in its own encoding;\n * {@link aggregation.dateDiff}. Wow 9.2 and later.\n */\nexport interface DateDiffAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.DATE_DIFF;\n /** The earlier instant, when the difference is positive. */\n from: QueryField<FIELDS>;\n /** The later instant, when the difference is positive. */\n to: QueryField<FIELDS>;\n /** The unit the difference is measured in. */\n unit: DateDiffUnit;\n}\n\n/**\n * Per-row arithmetic over fields, time differences and numbers, which a\n * metric aggregates, a TERMS or HISTOGRAM group groups by, and an\n * `EXPRESSION` filter compares. A tree at most\n * `AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH` deep and `MAX_EXPRESSION_NODES`\n * large, counted over a query's metrics together and over each group or\n * filter on its own.\n */\nexport type AggregationExpression<FIELDS extends string = string> =\n | FieldAggregationExpression<FIELDS>\n | ConstantAggregationExpression\n | BinaryAggregationExpression<FIELDS>\n | DateDiffAggregationExpression<FIELDS>;\n\n/** The number of rows in each group; {@link aggregation.count}. */\nexport interface CountAggregationMetric<FIELDS extends string = string> {\n /** Counts only the rows that match. Wow 9.1 and later. */\n filter?: FilterExpression<FIELDS>;\n type: AggregationMetricType.COUNT;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/**\n * An {@link AggregationFunction} of an expression; {@link aggregation.sum},\n * `avg`, `min`, `max`, `stddev`, `variance`.\n */\nexport interface NumericAggregationMetric<FIELDS extends string = string> {\n /** Aggregates only the rows that match. Wow 9.1 and later. */\n filter?: FilterExpression<FIELDS>;\n type: AggregationMetricType.NUMERIC;\n /** What is computed. */\n function: AggregationFunction;\n /** The per-row value it is computed over. */\n expression: AggregationExpression<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/**\n * Any one value of a field within each group, of any type;\n * {@link aggregation.any}. Wow 9.0 and later. Neither a derived metric nor\n * `having` may refer to it.\n */\nexport interface AnyAggregationMetric<FIELDS extends string = string> {\n /** Aggregates only the rows that match. Wow 9.1 and later. */\n filter?: FilterExpression<FIELDS>;\n type: AggregationMetricType.ANY;\n /** The field whose value is taken. */\n field: QueryField<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/**\n * A field's value on the earliest (`FIRST`) or latest (`LAST`) record of\n * each group, ordered by `orderBy`; {@link aggregation.first} and\n * {@link aggregation.last}. Wow 9.2 and later.\n *\n * The value comes back in the field's own type, not as a number, and is\n * `null` when no record of the group has both a value and an `orderBy`\n * position. Without `orderBy` the server orders by the model's event time,\n * the field the descriptor names as `analysis.firstLastOrderBy`. Records\n * tied on `orderBy` may yield any one of their values. Like `ANY`, neither a\n * derived metric nor `having` may refer to it.\n */\nexport interface EdgeAggregationMetric<FIELDS extends string = string> {\n type: AggregationMetricType.FIRST | AggregationMetricType.LAST;\n /** The single-valued field whose value is taken. */\n field: QueryField<FIELDS>;\n /**\n * The single-valued, sortable field that orders the records; the model's\n * event time when absent.\n */\n orderBy?: QueryField<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n /** Aggregates only the rows that match. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/**\n * The number of distinct values of an expression;\n * {@link aggregation.distinctCount}. Wow 9.1 and later.\n */\nexport interface DistinctCountAggregationMetric<\n FIELDS extends string = string,\n> {\n type: AggregationMetricType.DISTINCT_COUNT;\n /** The per-row value whose distinct values are counted. */\n expression: AggregationExpression<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n /** Aggregates only the rows that match. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/**\n * A percentile of an expression; {@link aggregation.percentile}. Wow 9.1 and\n * later.\n */\nexport interface PercentileAggregationMetric<FIELDS extends string = string> {\n type: AggregationMetricType.PERCENTILE;\n /** The per-row value the percentile is taken over. */\n expression: AggregationExpression<FIELDS>;\n /** Which percentile, within (0, 100). */\n percentile: number;\n /** The name of the metric's column in the result rows. */\n alias: string;\n /** Aggregates only the rows that match. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/** The kind of a {@link DerivedExpression} node, sent as its `type`. */\nexport enum DerivedExpressionType {\n /** The value of another metric of the row, by its alias. */\n METRIC_REF = 'METRIC_REF',\n /** A number. */\n CONSTANT = 'CONSTANT',\n /** Two operands and an {@link AggregationExpressionOperator}. */\n BINARY = 'BINARY',\n}\n\n/**\n * Post-aggregation arithmetic; references must name earlier metrics that are\n * not `ANY`, `FIRST` or `LAST`.\n */\nexport type DerivedExpression =\n | { type: DerivedExpressionType.METRIC_REF; metric: string }\n | { type: DerivedExpressionType.CONSTANT; value: number }\n | {\n type: DerivedExpressionType.BINARY;\n operator: AggregationExpressionOperator;\n left: DerivedExpression;\n right: DerivedExpression;\n };\n\n/**\n * A metric computed from metrics declared before it in the same query, after\n * aggregation; {@link aggregation.derived}. Wow 9.1 and later.\n */\nexport interface DerivedAggregationMetric {\n type: AggregationMetricType.DERIVED;\n /** The arithmetic over the other metrics. */\n expression: DerivedExpression;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/** The kind of a {@link HavingExpression} node, sent as its `type`. */\nexport enum HavingExpressionType {\n /** A metric compared with a number; `aggregation.having.eq` … `lte`. */\n CONDITION = 'CONDITION',\n /** A metric within bounds, inclusive; `aggregation.having.between`. */\n BETWEEN = 'BETWEEN',\n /** A metric equal to one of the numbers; `aggregation.having.isIn`. */\n IN = 'IN',\n /**\n * A metric without a value, or with one when `negated`;\n * `aggregation.having.isNull`, `isNotNull`.\n */\n IS_NULL = 'IS_NULL',\n /** All operands hold; `aggregation.having.and`. */\n AND = 'AND',\n /** At least one operand holds; `aggregation.having.or`. */\n OR = 'OR',\n}\n\n/** The comparison of a `CONDITION` in a {@link HavingExpression}. */\nexport enum ComparisonOperator {\n /** `=` */\n EQ = 'EQ',\n /** `≠` */\n NE = 'NE',\n /** `>` */\n GT = 'GT',\n /** `≥` */\n GTE = 'GTE',\n /** `<` */\n LT = 'LT',\n /** `≤` */\n LTE = 'LTE',\n}\n\n/**\n * Filters grouped results by metric aliases, before sorting/limit; never an\n * `ANY`, `FIRST` or `LAST` metric.\n */\nexport type HavingExpression =\n | {\n type: HavingExpressionType.CONDITION;\n metric: string;\n operator: ComparisonOperator;\n value: number;\n }\n | {\n type: HavingExpressionType.BETWEEN;\n metric: string;\n lower: number;\n upper: number;\n }\n | {\n type: HavingExpressionType.IN;\n metric: string;\n values: [number, ...number[]];\n }\n | { type: HavingExpressionType.IS_NULL; metric: string; negated?: boolean }\n | {\n type: HavingExpressionType.AND | HavingExpressionType.OR;\n operands: [HavingExpression, ...HavingExpression[]];\n };\n\n/**\n * One column an {@link AggregationQuery} computes for each group; a query\n * takes 1 to `AGGREGATION_LIMITS.MAX_METRICS` of them.\n */\nexport type AggregationMetric<FIELDS extends string = string> =\n | CountAggregationMetric<FIELDS>\n | NumericAggregationMetric<FIELDS>\n | AnyAggregationMetric<FIELDS>\n | DistinctCountAggregationMetric<FIELDS>\n | PercentileAggregationMetric<FIELDS>\n | DerivedAggregationMetric\n | EdgeAggregationMetric<FIELDS>;\n\n/**\n * An aggregation request: which documents, grouped how, computing which\n * metrics. `QueryApi.aggregate` and `aggregateStream` send it, and each\n * result row holds the groups' and metrics' columns by alias. Assemble it\n * with {@link aggregation.query}, which checks the rules Wow enforces across\n * its parts before anything is sent.\n *\n * Wow 8.11 has no aggregation endpoint; Wow 8.12 added it with `COUNT` and\n * `NUMERIC` metrics, and Wow 9.0 added `ANY`. `having`, the `DISTINCT_COUNT`,\n * `PERCENTILE` and `DERIVED` metrics, metric filters, `missingKey` and `dense`\n * need Wow 9.1.\n *\n * @template ROOT_FIELDS - The fields `filter` may name\n * @template AGGREGATION_FIELDS - The fields groups and metrics may name\n */\nexport interface AggregationQuery<\n ROOT_FIELDS extends string = string,\n AGGREGATION_FIELDS extends string = ROOT_FIELDS,\n> {\n /** Which documents are aggregated; all of them when absent. */\n filter?: FilterExpression<ROOT_FIELDS>;\n /** Array fields to aggregate the elements of, instead of the documents. */\n elements?: AggregationElement[];\n /** The dimensions of the result; one row in total when absent or empty. */\n groupBy?: AggregationGroup<AGGREGATION_FIELDS>[];\n /** The columns computed for each group. */\n metrics: [\n AggregationMetric<AGGREGATION_FIELDS>,\n ...AggregationMetric<AGGREGATION_FIELDS>[],\n ];\n /**\n * The order of the rows, by group or metric alias; needs a `groupBy`. Wow\n * then sorts by each remaining group ascending.\n */\n sort?: FieldSort[];\n /**\n * The most rows returned, 1 to `AGGREGATION_LIMITS.MAX_LIMIT`; the\n * server returns `DEFAULT_LIMIT` (100) when absent.\n */\n limit?: number;\n /**\n * Keeps only the grouped rows whose metrics match, before `sort` and\n * `limit`; built with {@link aggregation.having}. Needs a `groupBy`.\n */\n having?: HavingExpression;\n}\n\n/**\n * The options every metric builder takes after its target and alias.\n */\nexport interface AggregationMetricOptions<FIELDS extends string = string> {\n /** Counts only the rows that match; sent as the metric's `filter`. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/** The options of {@link aggregation.terms}. */\nexport interface TermsAggregationOptions {\n /** The key rows without a value are grouped under; must not be blank. */\n missingKey?: string;\n}\n\n/** The options of {@link aggregation.histogram}. */\nexport interface HistogramAggregationOptions {\n /** The width of each bucket: finite and greater than 0. */\n interval: number;\n}\n\n/** The options of {@link aggregation.dateHistogram}. */\nexport interface DateHistogramAggregationOptions {\n /** The calendar unit of each bucket. */\n unit: AggregationDateUnit;\n /** The zone the buckets are cut in, an IANA id. Defaults to `UTC`. */\n timeZone?: string;\n /**\n * Whether the server fills in the empty buckets of the range. Only when\n * this is the only group.\n */\n dense?: boolean;\n}\n\n/** The options of {@link aggregation.datePart}. */\nexport interface DatePartAggregationOptions {\n /** The calendar part each row is grouped by. */\n part: AggregationDatePart;\n /** The zone the part is read in, an IANA id. Defaults to `UTC`. */\n timeZone?: string;\n /**\n * Whether the server returns every key of the part's domain, the empty\n * ones filled in. Only when this is the only group.\n */\n dense?: boolean;\n}\n\n/** The options of {@link aggregation.first} and {@link aggregation.last}. */\nexport interface EdgeAggregationOptions<\n FIELDS extends string = string,\n> extends AggregationMetricOptions<FIELDS> {\n /**\n * The single-valued, sortable field that orders the records. Defaults to\n * the model's event time, `analysis.firstLastOrderBy` in the descriptor.\n */\n orderBy?: FIELDS;\n}\n\n/** The options of {@link aggregation.percentile}. */\nexport interface PercentileAggregationOptions<\n FIELDS extends string = string,\n> extends AggregationMetricOptions<FIELDS> {\n /** Which percentile: finite and within (0, 100). */\n percentile: number;\n}\n\n/**\n * The sizes Wow's own `AggregationQuery` enforces by throwing.\n *\n * A query that breaks one of them is refused by the server, which says what\n * was wrong but not which metric or group said it. Checking here keeps the\n * complaint next to the call that built the query.\n */\nexport const AGGREGATION_LIMITS = Object.freeze({\n /** Rows returned when a query names no limit of its own. */\n DEFAULT_LIMIT: 100,\n /** The largest `limit`. */\n MAX_LIMIT: 10_000,\n /** The most `elements`. */\n MAX_ELEMENTS: 5,\n /** The most `groupBy` entries. */\n MAX_GROUPS: 32,\n /** The most `metrics`. */\n MAX_METRICS: 64,\n /** The most `sort` fields, including those Wow appends for the groups. */\n MAX_SORT_FIELDS: 32,\n /** The deepest expression tree. */\n MAX_EXPRESSION_DEPTH: 8,\n /** The most expression nodes in the whole query. */\n MAX_EXPRESSION_NODES: 256,\n});\n"],"mappings":";AAsBA,IAAYA,IAAL,yBAAA,GAAA;QAEL,EAAAC,QAAA,SAEA,EAAAC,YAAA,aAEA,EAAAC,iBAAA,kBAKA,EAAAC,YAAA;AACF,EAAA,CAAA,CAAA,GAOYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,QAAA,SAKA,EAAAC,UAAA,WAEA,EAAAC,MAAA,OAKA,EAAAC,iBAAA,kBAKA,EAAAC,aAAA,cAKA,EAAAC,UAAA,WAKA,EAAAC,QAAA,SAKA,EAAAC,OAAA;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,QAAA,SAEA,EAAAC,WAAA,YAEA,EAAAC,SAAA,UAKA,EAAAC,YAAA;AACF,EAAA,CAAA,CAAA,GAOYC,IAAL,yBAAA,GAAA;QACL,EAAAC,SAAA,UACA,EAAAC,SAAA,UACA,EAAAC,OAAA,QACA,EAAAC,MAAA;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,MAAA,OAEA,EAAAC,WAAA,YAEA,EAAAC,WAAA,YAEA,EAAAC,SAAA;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;QACL,EAAAC,OAAA,QACA,EAAAC,UAAA,WACA,EAAAC,QAAA,SACA,EAAAC,OAAA,QACA,EAAAV,MAAA,OACA,EAAAD,OAAA,QACA,EAAAD,SAAA,UACA,EAAAD,SAAA;AACF,EAAA,CAAA,CAAA,GAOYc,IAAL,yBAAA,GAAA;QAEL,EAAAC,cAAA,eAKA,EAAAC,eAAA,gBAEA,EAAAC,cAAA,eAEA,EAAAC,gBAAA;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,MAAA,OAEA,EAAAC,MAAA,OAEA,EAAAC,MAAA,OAEA,EAAAC,MAAA,OAEA,EAAAC,SAAA,UAEA,EAAAC,WAAA;AACF,EAAA,CAAA,CAAA,GAqRYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,aAAA,cAEA,EAAA/B,WAAA,YAEA,EAAAC,SAAA;AACF,EAAA,CAAA,CAAA,GA6BY+B,IAAL,yBAAA,GAAA;QAEL,EAAAC,YAAA,aAEA,EAAAC,UAAA,WAEA,EAAAC,KAAA,MAKA,EAAAC,UAAA,WAEA,EAAAC,MAAA,OAEA,EAAAC,KAAA;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,KAAA,MAEA,EAAAC,KAAA,MAEA,EAAAC,KAAA,MAEA,EAAAC,MAAA,OAEA,EAAAC,KAAA,MAEA,EAAAC,MAAA;AACF,EAAA,CAAA,CAAA,GAkKaC,IAAqB,OAAO,OAAO;CAE9C,eAAe;CAEf,WAAW;CAEX,cAAc;CAEd,YAAY;CAEZ,aAAa;CAEb,iBAAiB;CAEjB,sBAAsB;CAEtB,sBAAsB;AACxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.es.js","names":["AggregationGroupType","\"TERMS\"","\"HISTOGRAM\"","\"DATE_HISTOGRAM\"","\"DATE_PART\"","AggregationGroupScope","\"ELEMENT\"","\"ROOT\"","AggregationMetricType","\"COUNT\"","\"NUMERIC\"","\"ANY\"","\"DISTINCT_COUNT\"","\"PERCENTILE\"","\"DERIVED\"","\"FIRST\"","\"LAST\"","AggregationExpressionType","\"FIELD\"","\"CONSTANT\"","\"BINARY\"","\"DATE_DIFF\"","DateDiffUnit","\"SECOND\"","\"MINUTE\"","\"HOUR\"","\"DAY\"","AggregationExpressionOperator","\"ADD\"","\"SUBTRACT\"","\"MULTIPLY\"","\"DIVIDE\"","AggregationDateUnit","\"YEAR\"","\"QUARTER\"","\"MONTH\"","\"WEEK\"","AggregationDatePart","\"DAY_OF_WEEK\"","\"DAY_OF_MONTH\"","\"HOUR_OF_DAY\"","\"MONTH_OF_YEAR\"","AggregationFunction","\"SUM\"","\"AVG\"","\"MIN\"","\"MAX\"","\"STDDEV\"","\"VARIANCE\"","DerivedExpressionType","\"METRIC_REF\"","\"TOTAL\"","\"RUNNING\"","\"PREVIOUS\"","\"RANK\"","WindowFunction","RunningFunction","HavingExpressionType","\"CONDITION\"","\"BETWEEN\"","\"IN\"","\"IS_NULL\"","\"AND\"","\"OR\"","ComparisonOperator","\"EQ\"","\"NE\"","\"GT\"","\"GTE\"","\"LT\"","\"LTE\"","AGGREGATION_LIMITS"],"sources":["../../../src/dsl/aggregation/types.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ElementFilterExpression,\n FilterExpression,\n QueryField,\n ExpressionFilter,\n} from '../filter/index.js';\nimport type { FieldSort, SortDirection } from '../sort.js';\n\n/** The kind of an {@link AggregationGroup}, sent as its `type`. */\nexport enum AggregationGroupType {\n /** One group per distinct value; {@link aggregation.terms}. */\n TERMS = 'TERMS',\n /** Number buckets of equal width; {@link aggregation.histogram}. */\n HISTOGRAM = 'HISTOGRAM',\n /** Calendar buckets of a time field; {@link aggregation.dateHistogram}. */\n DATE_HISTOGRAM = 'DATE_HISTOGRAM',\n /**\n * One calendar part of a time field, such as the weekday or the hour;\n * {@link aggregation.datePart}. Wow 9.2 and later.\n */\n DATE_PART = 'DATE_PART',\n}\n\n/**\n * What an {@link AggregationGroup}'s field is relative to when the query\n * expands elements, sent as its `scope`. Wow 9.9 and later.\n */\nexport enum AggregationGroupScope {\n /** The innermost expanded element; the default. */\n ELEMENT = 'ELEMENT',\n /** The root record, so the elements are grouped by a field of their root. */\n ROOT = 'ROOT',\n}\n\n/**\n * The kind of an {@link AggregationMetric}, sent as its `type`. Wow 8.12\n * knows `COUNT` and `NUMERIC`, Wow 9.0 adds `ANY`, and the other three need\n * Wow 9.1.\n */\nexport enum AggregationMetricType {\n /** The number of rows; {@link aggregation.count}. */\n COUNT = 'COUNT',\n /**\n * An {@link AggregationFunction} of an expression; {@link aggregation.sum}\n * and its siblings.\n */\n NUMERIC = 'NUMERIC',\n /** Any one value of a field; {@link aggregation.any}. Wow 9.0 and later. */\n ANY = 'ANY',\n /**\n * The number of distinct values; {@link aggregation.distinctCount}. Wow 9.1\n * and later.\n */\n DISTINCT_COUNT = 'DISTINCT_COUNT',\n /**\n * A percentile of an expression; {@link aggregation.percentile}. Wow 9.1\n * and later.\n */\n PERCENTILE = 'PERCENTILE',\n /**\n * Arithmetic over other metrics; {@link aggregation.derived}. Wow 9.1 and\n * later.\n */\n DERIVED = 'DERIVED',\n /**\n * A field's value on the group's earliest record; {@link aggregation.first}.\n * Wow 9.2 and later.\n */\n FIRST = 'FIRST',\n /**\n * A field's value on the group's latest record; {@link aggregation.last}.\n * Wow 9.2 and later.\n */\n LAST = 'LAST',\n}\n\n/** The kind of an {@link AggregationExpression} node, sent as its `type`. */\nexport enum AggregationExpressionType {\n /** The value of a field; {@link aggregation.field}. */\n FIELD = 'FIELD',\n /** A number; {@link aggregation.constant}. */\n CONSTANT = 'CONSTANT',\n /** Two operands and an {@link AggregationExpressionOperator}. */\n BINARY = 'BINARY',\n /**\n * The time elapsed between two time fields; {@link aggregation.dateDiff}.\n * Wow 9.2 and later.\n */\n DATE_DIFF = 'DATE_DIFF',\n}\n\n/**\n * The unit a `DATE_DIFF` measures elapsed time in. Each has a fixed length:\n * a `DAY` is exactly 24 hours, and months and years, whose length depends on\n * a calendar and a time zone, are not offered.\n */\nexport enum DateDiffUnit {\n SECOND = 'SECOND',\n MINUTE = 'MINUTE',\n HOUR = 'HOUR',\n DAY = 'DAY',\n}\n\n/**\n * The arithmetic of a `BINARY` node, in an {@link AggregationExpression} or a\n * {@link DerivedExpression}.\n */\nexport enum AggregationExpressionOperator {\n /** `left + right` */\n ADD = 'ADD',\n /** `left - right` */\n SUBTRACT = 'SUBTRACT',\n /** `left * right` */\n MULTIPLY = 'MULTIPLY',\n /** `left / right` */\n DIVIDE = 'DIVIDE',\n}\n\n/**\n * The calendar unit of a `DATE_HISTOGRAM` bucket, cut in the group's\n * `timeZone`.\n */\nexport enum AggregationDateUnit {\n YEAR = 'YEAR',\n QUARTER = 'QUARTER',\n MONTH = 'MONTH',\n WEEK = 'WEEK',\n DAY = 'DAY',\n HOUR = 'HOUR',\n MINUTE = 'MINUTE',\n SECOND = 'SECOND',\n}\n\n/**\n * The calendar part a `DATE_PART` group takes of each instant, read in the\n * group's `timeZone`. Its keys are integers from a fixed domain, so records\n * from different days, weeks or years fall into one bucket.\n */\nexport enum AggregationDatePart {\n /** The ISO weekday: 1 is Monday, 7 is Sunday. */\n DAY_OF_WEEK = 'DAY_OF_WEEK',\n /**\n * The day of the month, 1 to 31; days 29 to 31 exist only in the months\n * that have them.\n */\n DAY_OF_MONTH = 'DAY_OF_MONTH',\n /** The hour on the wall clock of the group's `timeZone`, 0 to 23. */\n HOUR_OF_DAY = 'HOUR_OF_DAY',\n /** The month of the year, 1 (January) to 12. */\n MONTH_OF_YEAR = 'MONTH_OF_YEAR',\n}\n\n/**\n * What a `NUMERIC` metric computes over its expression; each has a builder,\n * {@link aggregation.sum} through {@link aggregation.variance}.\n */\nexport enum AggregationFunction {\n /** The sum */\n SUM = 'SUM',\n /** The average */\n AVG = 'AVG',\n /** The least value */\n MIN = 'MIN',\n /** The greatest value */\n MAX = 'MAX',\n /** The standard deviation */\n STDDEV = 'STDDEV',\n /** The variance */\n VARIANCE = 'VARIANCE',\n}\n\n/**\n * An array field whose elements the query aggregates over instead of the\n * root documents; build it with {@link aggregation.element}. A query takes at\n * most `AGGREGATION_LIMITS.MAX_ELEMENTS` of them.\n */\nexport interface AggregationElement {\n /** The array field, a query field path. */\n path: QueryField;\n /**\n * Keeps only the elements that match; no root filters and no search, but\n * an `EXPRESSION` filter may compare an element's computed value.\n */\n filter?: ElementFilterExpression | ExpressionFilter;\n}\n\n/** What every {@link AggregationGroup} has. */\ninterface AggregationGroupBase<FIELDS extends string = string> {\n /** The field the rows are grouped by. */\n field: QueryField<FIELDS>;\n /** The name of the group's column in the result rows. */\n alias: string;\n /**\n * What `field` is relative to when the query expands elements: the\n * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).\n * A `ROOT` group names a field, never an expression. Wow 9.9 and later,\n * where `analysis.rootGroups` is `true`.\n */\n scope?: AggregationGroupScope;\n}\n\n/**\n * What a TERMS or HISTOGRAM group groups by: a field, or a computed\n * expression in its place (Wow 9.2 and later), never both. An expression\n * input is an expensive computation the server admits only where\n * `analysis.expressions` is `true`.\n */\nexport type AggregationGroupInput<FIELDS extends string = string> =\n | {\n /** The field the rows are grouped by. */\n field: QueryField<FIELDS>;\n expression?: undefined;\n }\n | {\n field?: undefined;\n /** The per-row value the rows are grouped by, such as a `DATE_DIFF`. */\n expression: AggregationExpression<FIELDS>;\n };\n\n/**\n * One group per distinct value of a field, or of an expression;\n * {@link aggregation.terms}. `missingKey` needs a field.\n */\nexport type TermsAggregationGroup<FIELDS extends string = string> = {\n type: AggregationGroupType.TERMS;\n /** The name of the group's column in the result rows. */\n alias: string;\n /** The key the rows without a value are grouped under. Wow 9.1 and later. */\n missingKey?: string;\n /**\n * What `field` is relative to when the query expands elements: the\n * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).\n * A `ROOT` group names a field, never an expression. Wow 9.9 and later,\n * where `analysis.rootGroups` is `true`.\n */\n scope?: AggregationGroupScope;\n} & AggregationGroupInput<FIELDS>;\n\n/**\n * Buckets of equal width over a number field, or over an expression;\n * {@link aggregation.histogram}.\n */\nexport type HistogramAggregationGroup<FIELDS extends string = string> = {\n type: AggregationGroupType.HISTOGRAM;\n /** The name of the group's column in the result rows. */\n alias: string;\n /** The width of each bucket, greater than 0. */\n interval: number;\n /**\n * What `field` is relative to when the query expands elements: the\n * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).\n * A `ROOT` group names a field, never an expression. Wow 9.9 and later,\n * where `analysis.rootGroups` is `true`.\n */\n scope?: AggregationGroupScope;\n} & AggregationGroupInput<FIELDS>;\n\n/**\n * Calendar buckets over a time field in epoch milliseconds;\n * {@link aggregation.dateHistogram}.\n */\nexport interface DateHistogramAggregationGroup<\n FIELDS extends string = string,\n> extends AggregationGroupBase<FIELDS> {\n type: AggregationGroupType.DATE_HISTOGRAM;\n /** The calendar unit of each bucket. */\n unit: AggregationDateUnit;\n /** The IANA zone the buckets are cut in; `UTC` when absent. */\n timeZone?: string;\n /**\n * Whether the server fills in the empty buckets of the range. Wow 9.1 and\n * later, and only when this is the query's only group.\n */\n dense?: boolean;\n}\n\n/**\n * One calendar part of a time field in epoch milliseconds, such as the\n * weekday or the hour; {@link aggregation.datePart}. Its keys in the result\n * rows are integers from the part's domain, such as 1 (Monday) to 7 (Sunday)\n * for `DAY_OF_WEEK`. Wow 9.2 and later.\n */\nexport interface DatePartAggregationGroup<\n FIELDS extends string = string,\n> extends AggregationGroupBase<FIELDS> {\n type: AggregationGroupType.DATE_PART;\n /** The calendar part each row is grouped by. */\n part: AggregationDatePart;\n /** The IANA zone the part is read in; `UTC` when absent. */\n timeZone?: string;\n /**\n * Whether the server returns every key of the part's domain, filling a\n * key with no records with each metric's empty value. Only when this is\n * the query's only group.\n */\n dense?: boolean;\n}\n\n/**\n * One dimension of an {@link AggregationQuery}'s `groupBy`: each result row\n * is one combination of the groups' keys.\n */\nexport type AggregationGroup<FIELDS extends string = string> =\n | TermsAggregationGroup<FIELDS>\n | HistogramAggregationGroup<FIELDS>\n | DateHistogramAggregationGroup<FIELDS>\n | DatePartAggregationGroup<FIELDS>;\n\n/** The value of a field, as an operand; {@link aggregation.field}. */\nexport interface FieldAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.FIELD;\n /** The field, a query field path. */\n field: QueryField<FIELDS>;\n}\n\n/** A number, as an operand; {@link aggregation.constant}. */\nexport interface ConstantAggregationExpression {\n type: AggregationExpressionType.CONSTANT;\n /** A finite number. */\n value: number;\n}\n\n/**\n * `left operator right`; {@link aggregation.add}, {@link aggregation.subtract},\n * {@link aggregation.multiply}, {@link aggregation.divide}.\n */\nexport interface BinaryAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.BINARY;\n /** The arithmetic. */\n operator: AggregationExpressionOperator;\n /** The left operand. */\n left: AggregationExpression<FIELDS>;\n /** The right operand. */\n right: AggregationExpression<FIELDS>;\n}\n\n/**\n * The time from the instant in `from` to the instant in `to`, `to − from`,\n * in `unit`, as a signed decimal: negative when `to` is earlier, and no\n * value when either is absent. Both are single-valued time fields (their\n * `aggregate.groups` list `DATE_HISTOGRAM`), each read in its own encoding;\n * {@link aggregation.dateDiff}. Wow 9.2 and later.\n */\nexport interface DateDiffAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.DATE_DIFF;\n /** The earlier instant, when the difference is positive. */\n from: QueryField<FIELDS>;\n /** The later instant, when the difference is positive. */\n to: QueryField<FIELDS>;\n /** The unit the difference is measured in. */\n unit: DateDiffUnit;\n}\n\n/**\n * Per-row arithmetic over fields, time differences and numbers, which a\n * metric aggregates, a TERMS or HISTOGRAM group groups by, and an\n * `EXPRESSION` filter compares. A tree at most\n * `AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH` deep and `MAX_EXPRESSION_NODES`\n * large, counted over a query's metrics together and over each group or\n * filter on its own.\n */\nexport type AggregationExpression<FIELDS extends string = string> =\n | FieldAggregationExpression<FIELDS>\n | ConstantAggregationExpression\n | BinaryAggregationExpression<FIELDS>\n | DateDiffAggregationExpression<FIELDS>;\n\n/** The number of rows in each group; {@link aggregation.count}. */\nexport interface CountAggregationMetric<FIELDS extends string = string> {\n /** Counts only the rows that match. Wow 9.1 and later. */\n filter?: FilterExpression<FIELDS>;\n type: AggregationMetricType.COUNT;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/**\n * An {@link AggregationFunction} of an expression; {@link aggregation.sum},\n * `avg`, `min`, `max`, `stddev`, `variance`.\n */\nexport interface NumericAggregationMetric<FIELDS extends string = string> {\n /** Aggregates only the rows that match. Wow 9.1 and later. */\n filter?: FilterExpression<FIELDS>;\n type: AggregationMetricType.NUMERIC;\n /** What is computed. */\n function: AggregationFunction;\n /** The per-row value it is computed over. */\n expression: AggregationExpression<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/**\n * Any one value of a field within each group, of any type;\n * {@link aggregation.any}. Wow 9.0 and later. Neither a derived metric nor\n * `having` may refer to it.\n */\nexport interface AnyAggregationMetric<FIELDS extends string = string> {\n /** Aggregates only the rows that match. Wow 9.1 and later. */\n filter?: FilterExpression<FIELDS>;\n type: AggregationMetricType.ANY;\n /** The field whose value is taken. */\n field: QueryField<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/**\n * A field's value on the earliest (`FIRST`) or latest (`LAST`) record of\n * each group, ordered by `orderBy`; {@link aggregation.first} and\n * {@link aggregation.last}. Wow 9.2 and later.\n *\n * The value comes back in the field's own type, not as a number, and is\n * `null` when no record of the group has both a value and an `orderBy`\n * position. Without `orderBy` the server orders by the model's event time,\n * the field the descriptor names as `analysis.firstLastOrderBy`. Records\n * tied on `orderBy` may yield any one of their values. Like `ANY`, neither a\n * derived metric nor `having` may refer to it.\n */\nexport interface EdgeAggregationMetric<FIELDS extends string = string> {\n type: AggregationMetricType.FIRST | AggregationMetricType.LAST;\n /** The single-valued field whose value is taken. */\n field: QueryField<FIELDS>;\n /**\n * The single-valued, sortable field that orders the records; the model's\n * event time when absent.\n */\n orderBy?: QueryField<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n /** Aggregates only the rows that match. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/**\n * The number of distinct values of an expression;\n * {@link aggregation.distinctCount}. Wow 9.1 and later.\n */\nexport interface DistinctCountAggregationMetric<\n FIELDS extends string = string,\n> {\n type: AggregationMetricType.DISTINCT_COUNT;\n /** The per-row value whose distinct values are counted. */\n expression: AggregationExpression<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n /** Aggregates only the rows that match. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/**\n * A percentile of an expression; {@link aggregation.percentile}. Wow 9.1 and\n * later.\n */\nexport interface PercentileAggregationMetric<FIELDS extends string = string> {\n type: AggregationMetricType.PERCENTILE;\n /** The per-row value the percentile is taken over. */\n expression: AggregationExpression<FIELDS>;\n /** Which percentile, within (0, 100). */\n percentile: number;\n /** The name of the metric's column in the result rows. */\n alias: string;\n /** Aggregates only the rows that match. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/** The kind of a {@link DerivedExpression} node, sent as its `type`. */\nexport enum DerivedExpressionType {\n /** The value of another metric of the row, by its alias. */\n METRIC_REF = 'METRIC_REF',\n /** A number. */\n CONSTANT = 'CONSTANT',\n /** Two operands and an {@link AggregationExpressionOperator}. */\n BINARY = 'BINARY',\n /** A window: the metric summed over a partition of the groups. */\n TOTAL = 'TOTAL',\n /** A window: the metric accumulated along an order, or its moving average. */\n RUNNING = 'RUNNING',\n /** A window: the metric of an earlier period along a date group. */\n PREVIOUS = 'PREVIOUS',\n /** A window: the dense rank of the metric within a partition. */\n RANK = 'RANK',\n}\n\n/**\n * The window functions of derived expressions, as a storage declares them in\n * `analysis.windows` of its descriptor.\n */\nexport enum WindowFunction {\n TOTAL = 'TOTAL',\n RUNNING = 'RUNNING',\n PREVIOUS = 'PREVIOUS',\n RANK = 'RANK',\n}\n\n/** What a `RUNNING` window computes over its frame. */\nexport enum RunningFunction {\n SUM = 'SUM',\n AVG = 'AVG',\n}\n\n/**\n * A window over the groups of the aggregation. Wow computes it over every\n * group the filter selects, before `having`, `sort` and `limit`; `metric`\n * names a non-derived numeric metric declared before the derived one, and\n * `within`, `order` and `along` name groups of the query. Wow 9.9 and later,\n * where `analysis.windows` lists the function.\n */\nexport type DerivedWindow =\n | {\n type: DerivedExpressionType.TOTAL;\n /** A `COUNT` or `SUM` metric. */\n metric: string;\n /** The partition's group aliases; every group when absent. */\n within?: string[];\n }\n | {\n type: DerivedExpressionType.RUNNING;\n /** A `COUNT` or `SUM` metric for `SUM`; any numeric metric for `AVG`. */\n metric: string;\n /** A group alias or a non-derived numeric metric, with its direction. */\n order: FieldSort;\n within?: string[];\n /** The last this many groups; every group up to this one when absent. */\n frame?: number;\n /** `SUM` when absent. */\n function?: RunningFunction;\n }\n | {\n type: DerivedExpressionType.PREVIOUS;\n metric: string;\n /** The alias of a `DATE_HISTOGRAM` group. */\n along: string;\n /** How many steps back; 1 when absent. */\n shift?: number;\n /** Step by this calendar period instead of by one bucket of `along`. */\n period?: AggregationDateUnit;\n }\n | {\n type: DerivedExpressionType.RANK;\n metric: string;\n within?: string[];\n /** `DESC` when absent. */\n direction?: SortDirection;\n };\n\n/**\n * Post-aggregation arithmetic; references must name earlier metrics that are\n * not `ANY`, `FIRST` or `LAST`.\n */\nexport type DerivedExpression =\n | { type: DerivedExpressionType.METRIC_REF; metric: string }\n | { type: DerivedExpressionType.CONSTANT; value: number }\n | {\n type: DerivedExpressionType.BINARY;\n operator: AggregationExpressionOperator;\n left: DerivedExpression;\n right: DerivedExpression;\n }\n | DerivedWindow;\n\n/**\n * A metric computed from metrics declared before it in the same query, after\n * aggregation; {@link aggregation.derived}. Wow 9.1 and later.\n */\nexport interface DerivedAggregationMetric {\n type: AggregationMetricType.DERIVED;\n /** The arithmetic over the other metrics. */\n expression: DerivedExpression;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/** The kind of a {@link HavingExpression} node, sent as its `type`. */\nexport enum HavingExpressionType {\n /** A metric compared with a number; `aggregation.having.eq` … `lte`. */\n CONDITION = 'CONDITION',\n /** A metric within bounds, inclusive; `aggregation.having.between`. */\n BETWEEN = 'BETWEEN',\n /** A metric equal to one of the numbers; `aggregation.having.isIn`. */\n IN = 'IN',\n /**\n * A metric without a value, or with one when `negated`;\n * `aggregation.having.isNull`, `isNotNull`.\n */\n IS_NULL = 'IS_NULL',\n /** All operands hold; `aggregation.having.and`. */\n AND = 'AND',\n /** At least one operand holds; `aggregation.having.or`. */\n OR = 'OR',\n}\n\n/** The comparison of a `CONDITION` in a {@link HavingExpression}. */\nexport enum ComparisonOperator {\n /** `=` */\n EQ = 'EQ',\n /** `≠` */\n NE = 'NE',\n /** `>` */\n GT = 'GT',\n /** `≥` */\n GTE = 'GTE',\n /** `<` */\n LT = 'LT',\n /** `≤` */\n LTE = 'LTE',\n}\n\n/**\n * Filters grouped results by metric aliases, before sorting/limit; never an\n * `ANY`, `FIRST` or `LAST` metric.\n */\nexport type HavingExpression =\n | {\n type: HavingExpressionType.CONDITION;\n metric: string;\n operator: ComparisonOperator;\n value: number;\n }\n | {\n type: HavingExpressionType.BETWEEN;\n metric: string;\n lower: number;\n upper: number;\n }\n | {\n type: HavingExpressionType.IN;\n metric: string;\n values: [number, ...number[]];\n }\n | { type: HavingExpressionType.IS_NULL; metric: string; negated?: boolean }\n | {\n type: HavingExpressionType.AND | HavingExpressionType.OR;\n operands: [HavingExpression, ...HavingExpression[]];\n };\n\n/**\n * One column an {@link AggregationQuery} computes for each group; a query\n * takes 1 to `AGGREGATION_LIMITS.MAX_METRICS` of them.\n */\nexport type AggregationMetric<FIELDS extends string = string> =\n | CountAggregationMetric<FIELDS>\n | NumericAggregationMetric<FIELDS>\n | AnyAggregationMetric<FIELDS>\n | DistinctCountAggregationMetric<FIELDS>\n | PercentileAggregationMetric<FIELDS>\n | DerivedAggregationMetric\n | EdgeAggregationMetric<FIELDS>;\n\n/**\n * An aggregation request: which documents, grouped how, computing which\n * metrics. `QueryApi.aggregate` and `aggregateStream` send it, and each\n * result row holds the groups' and metrics' columns by alias. Assemble it\n * with {@link aggregation.query}, which checks the rules Wow enforces across\n * its parts before anything is sent.\n *\n * Wow 8.11 has no aggregation endpoint; Wow 8.12 added it with `COUNT` and\n * `NUMERIC` metrics, and Wow 9.0 added `ANY`. `having`, the `DISTINCT_COUNT`,\n * `PERCENTILE` and `DERIVED` metrics, metric filters, `missingKey` and `dense`\n * need Wow 9.1.\n *\n * @template ROOT_FIELDS - The fields `filter` may name\n * @template AGGREGATION_FIELDS - The fields groups and metrics may name\n */\nexport interface AggregationQuery<\n ROOT_FIELDS extends string = string,\n AGGREGATION_FIELDS extends string = ROOT_FIELDS,\n> {\n /** Which documents are aggregated; all of them when absent. */\n filter?: FilterExpression<ROOT_FIELDS>;\n /** Array fields to aggregate the elements of, instead of the documents. */\n elements?: AggregationElement[];\n /** The dimensions of the result; one row in total when absent or empty. */\n groupBy?: AggregationGroup<AGGREGATION_FIELDS>[];\n /** The columns computed for each group. */\n metrics: [\n AggregationMetric<AGGREGATION_FIELDS>,\n ...AggregationMetric<AGGREGATION_FIELDS>[],\n ];\n /**\n * The order of the rows, by group or metric alias; needs a `groupBy`. Wow\n * then sorts by each remaining group ascending.\n */\n sort?: FieldSort[];\n /**\n * The most rows returned, 1 to `AGGREGATION_LIMITS.MAX_LIMIT`; the\n * server returns `DEFAULT_LIMIT` (100) when absent.\n */\n limit?: number;\n /**\n * Keeps only the grouped rows whose metrics match, before `sort` and\n * `limit`; built with {@link aggregation.having}. Needs a `groupBy`.\n */\n having?: HavingExpression;\n}\n\n/**\n * The options every metric builder takes after its target and alias.\n */\nexport interface AggregationMetricOptions<FIELDS extends string = string> {\n /** Counts only the rows that match; sent as the metric's `filter`. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/** The option every group builder takes. */\nexport interface AggregationGroupScopeOptions {\n /**\n * What the field is relative to when the query expands elements; the\n * innermost element when absent. `ROOT` needs a field input. Wow 9.9 and\n * later.\n */\n scope?: AggregationGroupScope;\n}\n\n/** The options of {@link aggregation.terms}. */\nexport interface TermsAggregationOptions extends AggregationGroupScopeOptions {\n /** The key rows without a value are grouped under; must not be blank. */\n missingKey?: string;\n}\n\n/** The options of {@link aggregation.histogram}. */\nexport interface HistogramAggregationOptions extends AggregationGroupScopeOptions {\n /** The width of each bucket: finite and greater than 0. */\n interval: number;\n}\n\n/** The options of {@link aggregation.dateHistogram}. */\nexport interface DateHistogramAggregationOptions extends AggregationGroupScopeOptions {\n /** The calendar unit of each bucket. */\n unit: AggregationDateUnit;\n /** The zone the buckets are cut in, an IANA id. Defaults to `UTC`. */\n timeZone?: string;\n /**\n * Whether the server fills in the empty buckets of the range. Only when\n * this is the only group.\n */\n dense?: boolean;\n}\n\n/** The options of {@link aggregation.datePart}. */\nexport interface DatePartAggregationOptions extends AggregationGroupScopeOptions {\n /** The calendar part each row is grouped by. */\n part: AggregationDatePart;\n /** The zone the part is read in, an IANA id. Defaults to `UTC`. */\n timeZone?: string;\n /**\n * Whether the server returns every key of the part's domain, the empty\n * ones filled in. Only when this is the only group.\n */\n dense?: boolean;\n}\n\n/** The options of {@link aggregation.first} and {@link aggregation.last}. */\nexport interface EdgeAggregationOptions<\n FIELDS extends string = string,\n> extends AggregationMetricOptions<FIELDS> {\n /**\n * The single-valued, sortable field that orders the records. Defaults to\n * the model's event time, `analysis.firstLastOrderBy` in the descriptor.\n */\n orderBy?: FIELDS;\n}\n\n/** The options of {@link aggregation.percentile}. */\nexport interface PercentileAggregationOptions<\n FIELDS extends string = string,\n> extends AggregationMetricOptions<FIELDS> {\n /** Which percentile: finite and within (0, 100). */\n percentile: number;\n}\n\n/**\n * The sizes Wow's own `AggregationQuery` enforces by throwing.\n *\n * A query that breaks one of them is refused by the server, which says what\n * was wrong but not which metric or group said it. Checking here keeps the\n * complaint next to the call that built the query.\n */\nexport const AGGREGATION_LIMITS = Object.freeze({\n /** Rows returned when a query names no limit of its own. */\n DEFAULT_LIMIT: 100,\n /** The largest `limit`. */\n MAX_LIMIT: 10_000,\n /** The most `elements`. */\n MAX_ELEMENTS: 5,\n /** The most `groupBy` entries. */\n MAX_GROUPS: 32,\n /** The most `metrics`. */\n MAX_METRICS: 64,\n /** The most `sort` fields, including those Wow appends for the groups. */\n MAX_SORT_FIELDS: 32,\n /** The deepest expression tree. */\n MAX_EXPRESSION_DEPTH: 8,\n /** The most expression nodes in the whole query. */\n MAX_EXPRESSION_NODES: 256,\n /** The most windows in the whole query. */\n MAX_WINDOWS: 8,\n});\n"],"mappings":";AAsBA,IAAYA,IAAL,yBAAA,GAAA;QAEL,EAAAC,QAAA,SAEA,EAAAC,YAAA,aAEA,EAAAC,iBAAA,kBAKA,EAAAC,YAAA;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,UAAA,WAEA,EAAAC,OAAA;AACF,EAAA,CAAA,CAAA,GAOYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,QAAA,SAKA,EAAAC,UAAA,WAEA,EAAAC,MAAA,OAKA,EAAAC,iBAAA,kBAKA,EAAAC,aAAA,cAKA,EAAAC,UAAA,WAKA,EAAAC,QAAA,SAKA,EAAAC,OAAA;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,QAAA,SAEA,EAAAC,WAAA,YAEA,EAAAC,SAAA,UAKA,EAAAC,YAAA;AACF,EAAA,CAAA,CAAA,GAOYC,IAAL,yBAAA,GAAA;QACL,EAAAC,SAAA,UACA,EAAAC,SAAA,UACA,EAAAC,OAAA,QACA,EAAAC,MAAA;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,MAAA,OAEA,EAAAC,WAAA,YAEA,EAAAC,WAAA,YAEA,EAAAC,SAAA;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;QACL,EAAAC,OAAA,QACA,EAAAC,UAAA,WACA,EAAAC,QAAA,SACA,EAAAC,OAAA,QACA,EAAAV,MAAA,OACA,EAAAD,OAAA,QACA,EAAAD,SAAA,UACA,EAAAD,SAAA;AACF,EAAA,CAAA,CAAA,GAOYc,IAAL,yBAAA,GAAA;QAEL,EAAAC,cAAA,eAKA,EAAAC,eAAA,gBAEA,EAAAC,cAAA,eAEA,EAAAC,gBAAA;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,MAAA,OAEA,EAAAC,MAAA,OAEA,EAAAC,MAAA,OAEA,EAAAC,MAAA,OAEA,EAAAC,SAAA,UAEA,EAAAC,WAAA;AACF,EAAA,CAAA,CAAA,GA0SYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,aAAA,cAEA,EAAA/B,WAAA,YAEA,EAAAC,SAAA,UAEA,EAAA+B,QAAA,SAEA,EAAAC,UAAA,WAEA,EAAAC,WAAA,YAEA,EAAAC,OAAA;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;QACL,EAAAJ,QAAA,SACA,EAAAC,UAAA,WACA,EAAAC,WAAA,YACA,EAAAC,OAAA;AACF,EAAA,CAAA,CAAA,GAGYE,IAAL,yBAAA,GAAA;QACL,EAAAb,MAAA,OACA,EAAAC,MAAA;AACF,EAAA,CAAA,CAAA,GA2EYa,IAAL,yBAAA,GAAA;QAEL,EAAAC,YAAA,aAEA,EAAAC,UAAA,WAEA,EAAAC,KAAA,MAKA,EAAAC,UAAA,WAEA,EAAAC,MAAA,OAEA,EAAAC,KAAA;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,KAAA,MAEA,EAAAC,KAAA,MAEA,EAAAC,KAAA,MAEA,EAAAC,MAAA,OAEA,EAAAC,KAAA,MAEA,EAAAC,MAAA;AACF,EAAA,CAAA,CAAA,GA4KaC,IAAqB,OAAO,OAAO;CAE9C,eAAe;CAEf,WAAW;CAEX,cAAc;CAEd,YAAY;CAEZ,aAAa;CAEb,iBAAiB;CAEjB,sBAAsB;CAEtB,sBAAsB;CAEtB,aAAa;AACf,CAAC"}
|
package/dist/dsl/descriptor.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=Object.freeze({SNAPSHOT:`SNAPSHOT`,EVENT_STREAM:`EVENT_STREAM`}),t=Object.freeze({STRING:`STRING`,INTEGER:`INTEGER`,DECIMAL:`DECIMAL`,BOOLEAN:`BOOLEAN`,OBJECT:`OBJECT`}),n=function(e){return e.UNKNOWN=`UNKNOWN`,e.NULL=`NULL`,e.SCALAR=`SCALAR`,e.OBJECT=`OBJECT`,e.ARRAY=`ARRAY`,e.UNION=`UNION`,e}({}),r=function(e){return e.LIST=`LIST`,e.PAGED=`PAGED`,e.CURSOR=`CURSOR`,e}({}),i=Object.freeze({IDENTITY:`IDENTITY`,AGGREGATE_ID:`AGGREGATE_ID`,TENANT_ID:`TENANT_ID`,OWNER_ID:`OWNER_ID`,SPACE_ID:`SPACE_ID`,DELETED:`DELETED`,EVENT_TIME:`EVENT_TIME`,FIRST_EVENT_TIME:`FIRST_EVENT_TIME`}),a=Object.freeze({CURSOR_UNIQUE_SORT:`CURSOR_UNIQUE_SORT`,COUNT_REQUIRES_FILTER:`COUNT_REQUIRES_FILTER`,STARTS_WITH_REQUIRES_PREFIX:`STARTS_WITH_REQUIRES_PREFIX`,PARALLEL_ARRAY_SORT:`PARALLEL_ARRAY_SORT`,NULL_OR_EMPTY_AS_MISSING:`NULL_OR_EMPTY_AS_MISSING`,ARRAY_EQUALITY:`ARRAY_EQUALITY`}),o=function(e){return e.DISPLAY=`DISPLAY`,e.CONFIDENTIAL=`CONFIDENTIAL`,e}({});exports.PagingMode=r,exports.QueryConstraintTypes=a,exports.QueryFieldRoles=i,exports.QueryModels=e,exports.QueryValueKind=n,exports.QueryValueTypes=t,exports.SensitivityLevel=o;
|
|
1
|
+
var e=Object.freeze({SNAPSHOT:`SNAPSHOT`,EVENT_STREAM:`EVENT_STREAM`,DATASET:`DATASET`}),t=Object.freeze({STRING:`STRING`,INTEGER:`INTEGER`,DECIMAL:`DECIMAL`,BOOLEAN:`BOOLEAN`,OBJECT:`OBJECT`}),n=function(e){return e.UNKNOWN=`UNKNOWN`,e.NULL=`NULL`,e.SCALAR=`SCALAR`,e.OBJECT=`OBJECT`,e.ARRAY=`ARRAY`,e.UNION=`UNION`,e}({}),r=function(e){return e.LIST=`LIST`,e.PAGED=`PAGED`,e.CURSOR=`CURSOR`,e}({}),i=Object.freeze({IDENTITY:`IDENTITY`,AGGREGATE_ID:`AGGREGATE_ID`,TENANT_ID:`TENANT_ID`,OWNER_ID:`OWNER_ID`,SPACE_ID:`SPACE_ID`,DELETED:`DELETED`,EVENT_TIME:`EVENT_TIME`,FIRST_EVENT_TIME:`FIRST_EVENT_TIME`}),a=Object.freeze({CURSOR_UNIQUE_SORT:`CURSOR_UNIQUE_SORT`,COUNT_REQUIRES_FILTER:`COUNT_REQUIRES_FILTER`,STARTS_WITH_REQUIRES_PREFIX:`STARTS_WITH_REQUIRES_PREFIX`,PARALLEL_ARRAY_SORT:`PARALLEL_ARRAY_SORT`,NULL_OR_EMPTY_AS_MISSING:`NULL_OR_EMPTY_AS_MISSING`,ARRAY_EQUALITY:`ARRAY_EQUALITY`}),o=function(e){return e.DISPLAY=`DISPLAY`,e.CONFIDENTIAL=`CONFIDENTIAL`,e}({});exports.PagingMode=r,exports.QueryConstraintTypes=a,exports.QueryFieldRoles=i,exports.QueryModels=e,exports.QueryValueKind=n,exports.QueryValueTypes=t,exports.SensitivityLevel=o;
|
|
2
2
|
//# sourceMappingURL=descriptor.cjs.map
|