@ahoo-wang/wow-client 10.0.0-beta.1 → 10.0.0-beta.2
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 +4 -2
- package/README.zh-CN.md +1 -1
- package/dist/commands.cjs +1 -1
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +1 -8
- package/dist/commands.d.ts +1 -8
- package/dist/commands.es.js +45 -51
- package/dist/commands.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 +73 -69
- package/dist/dsl/aggregation/admit.es.js.map +1 -1
- package/dist/dsl/aggregation/aliases.cjs +2 -0
- package/dist/dsl/aggregation/aliases.cjs.map +1 -0
- package/dist/dsl/aggregation/aliases.d.cts +2 -0
- package/dist/dsl/aggregation/aliases.d.ts +2 -0
- package/dist/dsl/aggregation/aliases.es.js +13 -0
- package/dist/dsl/aggregation/aliases.es.js.map +1 -0
- package/dist/dsl/aggregation/builders.cjs +1 -1
- package/dist/dsl/aggregation/builders.cjs.map +1 -1
- package/dist/dsl/aggregation/builders.d.cts +17 -243
- package/dist/dsl/aggregation/builders.d.ts +17 -243
- package/dist/dsl/aggregation/builders.es.js +36 -171
- 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 +123 -1
- package/dist/dsl/aggregation/derived.d.ts +123 -1
- package/dist/dsl/aggregation/derived.es.js +43 -28
- package/dist/dsl/aggregation/derived.es.js.map +1 -1
- package/dist/dsl/aggregation/groups.cjs +2 -0
- package/dist/dsl/aggregation/groups.cjs.map +1 -0
- package/dist/dsl/aggregation/groups.d.cts +325 -0
- package/dist/dsl/aggregation/groups.d.ts +325 -0
- package/dist/dsl/aggregation/groups.es.js +80 -0
- package/dist/dsl/aggregation/groups.es.js.map +1 -0
- package/dist/dsl/aggregation/having.cjs +1 -1
- package/dist/dsl/aggregation/having.cjs.map +1 -1
- package/dist/dsl/aggregation/having.d.cts +63 -1
- package/dist/dsl/aggregation/having.d.ts +63 -1
- package/dist/dsl/aggregation/having.es.js +33 -30
- package/dist/dsl/aggregation/having.es.js.map +1 -1
- package/dist/dsl/aggregation/index.d.cts +4 -2
- package/dist/dsl/aggregation/index.d.ts +4 -2
- package/dist/dsl/aggregation/metrics.cjs +2 -0
- package/dist/dsl/aggregation/metrics.cjs.map +1 -0
- package/dist/dsl/aggregation/metrics.d.cts +279 -0
- package/dist/dsl/aggregation/metrics.d.ts +279 -0
- package/dist/dsl/aggregation/metrics.es.js +75 -0
- package/dist/dsl/aggregation/metrics.es.js.map +1 -0
- package/dist/dsl/aggregation/types.cjs +1 -1
- package/dist/dsl/aggregation/types.cjs.map +1 -1
- package/dist/dsl/aggregation/types.d.cts +4 -524
- package/dist/dsl/aggregation/types.d.ts +4 -524
- package/dist/dsl/aggregation/types.es.js +5 -25
- package/dist/dsl/aggregation/types.es.js.map +1 -1
- package/dist/dsl/cursorQuery.cjs +1 -1
- package/dist/dsl/cursorQuery.cjs.map +1 -1
- package/dist/dsl/cursorQuery.d.cts +18 -7
- package/dist/dsl/cursorQuery.d.ts +18 -7
- package/dist/dsl/cursorQuery.es.js +13 -12
- package/dist/dsl/cursorQuery.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 +17 -379
- package/dist/dsl/descriptor.d.ts +17 -379
- package/dist/dsl/descriptor.es.js +4 -31
- package/dist/dsl/descriptor.es.js.map +1 -1
- package/dist/dsl/fieldDescriptor.cjs +2 -0
- package/dist/dsl/fieldDescriptor.cjs.map +1 -0
- package/dist/dsl/fieldDescriptor.d.cts +246 -0
- package/dist/dsl/fieldDescriptor.d.ts +246 -0
- package/dist/dsl/fieldDescriptor.es.js +24 -0
- package/dist/dsl/fieldDescriptor.es.js.map +1 -0
- package/dist/dsl/filter/builders.cjs +1 -1
- package/dist/dsl/filter/builders.cjs.map +1 -1
- package/dist/dsl/filter/builders.d.cts +7 -949
- package/dist/dsl/filter/builders.d.ts +7 -949
- package/dist/dsl/filter/builders.es.js +14 -285
- package/dist/dsl/filter/builders.es.js.map +1 -1
- package/dist/dsl/filter/expressionFilter.cjs +2 -0
- package/dist/dsl/filter/expressionFilter.cjs.map +1 -0
- package/dist/dsl/filter/expressionFilter.d.cts +35 -0
- package/dist/dsl/filter/expressionFilter.d.ts +35 -0
- package/dist/dsl/filter/expressionFilter.es.js +18 -0
- package/dist/dsl/filter/expressionFilter.es.js.map +1 -0
- package/dist/dsl/filter/fieldFilters.cjs +2 -0
- package/dist/dsl/filter/fieldFilters.cjs.map +1 -0
- package/dist/dsl/filter/fieldFilters.d.cts +297 -0
- package/dist/dsl/filter/fieldFilters.d.ts +297 -0
- package/dist/dsl/filter/fieldFilters.es.js +110 -0
- package/dist/dsl/filter/fieldFilters.es.js.map +1 -0
- package/dist/dsl/filter/index.d.cts +2 -1
- package/dist/dsl/filter/index.d.ts +2 -1
- package/dist/dsl/filter/logicalFilters.cjs +2 -0
- package/dist/dsl/filter/logicalFilters.cjs.map +1 -0
- package/dist/dsl/filter/logicalFilters.d.cts +109 -0
- package/dist/dsl/filter/logicalFilters.d.ts +109 -0
- package/dist/dsl/filter/logicalFilters.es.js +36 -0
- package/dist/dsl/filter/logicalFilters.es.js.map +1 -0
- package/dist/dsl/filter/metadataFilters.cjs +2 -0
- package/dist/dsl/filter/metadataFilters.cjs.map +1 -0
- package/dist/dsl/filter/metadataFilters.d.cts +132 -0
- package/dist/dsl/filter/metadataFilters.d.ts +132 -0
- package/dist/dsl/filter/metadataFilters.es.js +56 -0
- package/dist/dsl/filter/metadataFilters.es.js.map +1 -0
- package/dist/dsl/filter/operator.cjs +1 -1
- package/dist/dsl/filter/operator.cjs.map +1 -1
- package/dist/dsl/filter/operator.d.cts +11 -9
- package/dist/dsl/filter/operator.d.ts +11 -9
- package/dist/dsl/filter/operator.es.js +1 -1
- package/dist/dsl/filter/operator.es.js.map +1 -1
- package/dist/dsl/filter/searchFilter.cjs +2 -0
- package/dist/dsl/filter/searchFilter.cjs.map +1 -0
- package/dist/dsl/filter/searchFilter.d.cts +39 -0
- package/dist/dsl/filter/searchFilter.d.ts +39 -0
- package/dist/dsl/filter/searchFilter.es.js +19 -0
- package/dist/dsl/filter/searchFilter.es.js.map +1 -0
- package/dist/dsl/filter/timeFilters.cjs +2 -0
- package/dist/dsl/filter/timeFilters.cjs.map +1 -0
- package/dist/dsl/filter/timeFilters.d.cts +290 -0
- package/dist/dsl/filter/timeFilters.d.ts +290 -0
- package/dist/dsl/filter/timeFilters.es.js +89 -0
- package/dist/dsl/filter/timeFilters.es.js.map +1 -0
- package/dist/dsl/filter/types.d.cts +4 -14
- package/dist/dsl/filter/types.d.ts +4 -14
- package/dist/dsl/filter/validate.cjs +1 -1
- package/dist/dsl/filter/validate.cjs.map +1 -1
- package/dist/dsl/filter/validate.d.cts +2 -4
- package/dist/dsl/filter/validate.d.ts +2 -4
- package/dist/dsl/filter/validate.es.js +25 -31
- package/dist/dsl/filter/validate.es.js.map +1 -1
- package/dist/dsl/queryErrorCodes.cjs +1 -1
- package/dist/dsl/queryErrorCodes.cjs.map +1 -1
- package/dist/dsl/queryErrorCodes.d.cts +0 -2
- package/dist/dsl/queryErrorCodes.d.ts +0 -2
- package/dist/dsl/queryErrorCodes.es.js +0 -1
- package/dist/dsl/queryErrorCodes.es.js.map +1 -1
- package/dist/dsl/queryFilter.cjs +2 -0
- package/dist/dsl/queryFilter.cjs.map +1 -0
- package/dist/dsl/queryFilter.d.cts +3 -0
- package/dist/dsl/queryFilter.d.ts +3 -0
- package/dist/dsl/queryFilter.es.js +9 -0
- package/dist/dsl/queryFilter.es.js.map +1 -0
- package/dist/dsl/queryable.cjs +1 -1
- package/dist/dsl/queryable.cjs.map +1 -1
- package/dist/dsl/queryable.es.js +12 -16
- package/dist/dsl/queryable.es.js.map +1 -1
- package/dist/dsl/semanticTypes.cjs +2 -0
- package/dist/dsl/semanticTypes.cjs.map +1 -0
- package/dist/dsl/semanticTypes.d.cts +128 -0
- package/dist/dsl/semanticTypes.d.ts +128 -0
- package/dist/dsl/semanticTypes.es.js +13 -0
- package/dist/dsl/semanticTypes.es.js.map +1 -0
- package/dist/dsl.cjs +1 -1
- package/dist/dsl.d.cts +2 -0
- package/dist/dsl.d.ts +2 -0
- package/dist/dsl.es.js +14 -8
- package/dist/exactJson.cjs +2 -2
- package/dist/exactJson.cjs.map +1 -1
- package/dist/exactJson.d.cts +41 -16
- package/dist/exactJson.d.ts +41 -16
- package/dist/exactJson.es.js +104 -102
- package/dist/exactJson.es.js.map +1 -1
- package/dist/frameworkErrors.cjs.map +1 -1
- package/dist/frameworkErrors.d.cts +4 -4
- package/dist/frameworkErrors.d.ts +4 -4
- package/dist/frameworkErrors.es.js.map +1 -1
- package/dist/http.cjs +1 -1
- package/dist/http.cjs.map +1 -1
- package/dist/http.d.cts +29 -9
- package/dist/http.d.ts +29 -9
- package/dist/http.es.js +24 -19
- package/dist/http.es.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.es.js +12 -12
- package/dist/manifest.cjs +1 -1
- package/dist/manifest.cjs.map +1 -1
- package/dist/manifest.d.cts +24 -0
- package/dist/manifest.d.ts +24 -0
- package/dist/manifest.es.js +34 -6
- package/dist/manifest.es.js.map +1 -1
- package/dist/manifestTypes.d.cts +16 -1
- package/dist/manifestTypes.d.ts +16 -1
- package/dist/queries.cjs +1 -1
- package/dist/queries.cjs.map +1 -1
- package/dist/queries.d.cts +18 -8
- package/dist/queries.d.ts +18 -8
- package/dist/queries.es.js +46 -35
- package/dist/queries.es.js.map +1 -1
- package/dist/routes.cjs +1 -1
- package/dist/routes.cjs.map +1 -1
- package/dist/routes.d.cts +16 -3
- package/dist/routes.d.ts +16 -3
- package/dist/routes.es.js +24 -25
- package/dist/routes.es.js.map +1 -1
- package/dist/state.cjs +1 -1
- package/dist/state.cjs.map +1 -1
- package/dist/state.d.cts +21 -19
- package/dist/state.d.ts +21 -19
- package/dist/state.es.js +27 -22
- package/dist/state.es.js.map +1 -1
- package/dist/streams.cjs +1 -1
- package/dist/streams.cjs.map +1 -1
- package/dist/streams.d.cts +14 -7
- package/dist/streams.d.ts +14 -7
- package/dist/streams.es.js +65 -50
- package/dist/streams.es.js.map +1 -1
- package/dist/testing/wire.cjs +1 -1
- package/dist/testing/wire.cjs.map +1 -1
- package/dist/testing/wire.es.js +1 -1
- package/dist/testing/wire.es.js.map +1 -1
- package/dist/wait.cjs +1 -1
- package/dist/wait.cjs.map +1 -1
- package/dist/wait.d.cts +17 -4
- package/dist/wait.d.ts +17 -4
- package/dist/wait.es.js +36 -34
- package/dist/wait.es.js.map +1 -1
- package/dist/wire.cjs +1 -1
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +75 -31
- package/dist/wire.d.ts +75 -31
- package/dist/wire.es.js +1 -3
- package/dist/wire.es.js.map +1 -1
- package/package.json +5 -5
- package/dist/dsl/filter/datePattern.cjs +0 -2
- package/dist/dsl/filter/datePattern.cjs.map +0 -1
- package/dist/dsl/filter/datePattern.d.cts +0 -8
- package/dist/dsl/filter/datePattern.d.ts +0 -8
- package/dist/dsl/filter/datePattern.es.js +0 -96
- package/dist/dsl/filter/datePattern.es.js.map +0 -1
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { FilterExpression, QueryField } from '../filter/index.cjs';
|
|
2
|
+
import { DerivedAggregationMetric } from './derived.cjs';
|
|
3
|
+
import { AggregationExpression } from './types.cjs';
|
|
4
|
+
/**
|
|
5
|
+
* The kind of an {@link AggregationMetric}, sent as its `type`. Wow 8.12
|
|
6
|
+
* knows `COUNT` and `NUMERIC`, Wow 9.0 adds `ANY`, and the other three need
|
|
7
|
+
* Wow 9.1.
|
|
8
|
+
*/
|
|
9
|
+
export declare enum AggregationMetricType {
|
|
10
|
+
/** The number of rows; {@link metricBuilders.count | `aggregation.count`}. */
|
|
11
|
+
COUNT = "count",
|
|
12
|
+
/**
|
|
13
|
+
* An {@link AggregationFunction} of an expression; {@link metricBuilders.sum | `aggregation.sum`}
|
|
14
|
+
* and its siblings.
|
|
15
|
+
*/
|
|
16
|
+
NUMERIC = "numeric",
|
|
17
|
+
/** Any one value of a field; {@link metricBuilders.any | `aggregation.any`}. Wow 9.0 and later. */
|
|
18
|
+
ANY = "any",
|
|
19
|
+
/**
|
|
20
|
+
* The number of distinct values; {@link metricBuilders.distinctCount | `aggregation.distinctCount`}. Wow 9.1
|
|
21
|
+
* and later.
|
|
22
|
+
*/
|
|
23
|
+
DISTINCT_COUNT = "distinct-count",
|
|
24
|
+
/**
|
|
25
|
+
* A percentile of an expression; {@link metricBuilders.percentile | `aggregation.percentile`}. Wow 9.1
|
|
26
|
+
* and later.
|
|
27
|
+
*/
|
|
28
|
+
PERCENTILE = "percentile",
|
|
29
|
+
/**
|
|
30
|
+
* Arithmetic over other metrics; {@link aggregation.derived}. Wow 9.1 and
|
|
31
|
+
* later.
|
|
32
|
+
*/
|
|
33
|
+
DERIVED = "derived",
|
|
34
|
+
/**
|
|
35
|
+
* A field's value on the group's earliest record; {@link metricBuilders.first | `aggregation.first`}.
|
|
36
|
+
* Wow 9.2 and later.
|
|
37
|
+
*/
|
|
38
|
+
FIRST = "first",
|
|
39
|
+
/**
|
|
40
|
+
* A field's value on the group's latest record; {@link metricBuilders.last | `aggregation.last`}.
|
|
41
|
+
* Wow 9.2 and later.
|
|
42
|
+
*/
|
|
43
|
+
LAST = "last"
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* What a `NUMERIC` metric computes over its expression; each has a builder,
|
|
47
|
+
* {@link metricBuilders.sum | `aggregation.sum`} through {@link metricBuilders.variance | `aggregation.variance`}.
|
|
48
|
+
*/
|
|
49
|
+
export declare enum AggregationFunction {
|
|
50
|
+
/** The sum */
|
|
51
|
+
SUM = "sum",
|
|
52
|
+
/** The average */
|
|
53
|
+
AVG = "avg",
|
|
54
|
+
/** The least value */
|
|
55
|
+
MIN = "min",
|
|
56
|
+
/** The greatest value */
|
|
57
|
+
MAX = "max",
|
|
58
|
+
/** The standard deviation */
|
|
59
|
+
STDDEV = "stddev",
|
|
60
|
+
/** The variance */
|
|
61
|
+
VARIANCE = "variance"
|
|
62
|
+
}
|
|
63
|
+
/** The number of rows in each group; {@link metricBuilders.count | `aggregation.count`}. */
|
|
64
|
+
export interface CountAggregationMetric<FIELDS extends string = string> {
|
|
65
|
+
/** Counts only the rows that match. Wow 9.1 and later. */
|
|
66
|
+
filter?: FilterExpression<FIELDS>;
|
|
67
|
+
type: AggregationMetricType.COUNT;
|
|
68
|
+
/** The name of the metric's column in the result rows. */
|
|
69
|
+
alias: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* An {@link AggregationFunction} of an expression; {@link metricBuilders.sum | `aggregation.sum`},
|
|
73
|
+
* `avg`, `min`, `max`, `stddev`, `variance`.
|
|
74
|
+
*/
|
|
75
|
+
export interface NumericAggregationMetric<FIELDS extends string = string> {
|
|
76
|
+
/** Aggregates only the rows that match. Wow 9.1 and later. */
|
|
77
|
+
filter?: FilterExpression<FIELDS>;
|
|
78
|
+
type: AggregationMetricType.NUMERIC;
|
|
79
|
+
/** What is computed. */
|
|
80
|
+
function: AggregationFunction;
|
|
81
|
+
/** The per-row value it is computed over. */
|
|
82
|
+
expression: AggregationExpression<FIELDS>;
|
|
83
|
+
/** The name of the metric's column in the result rows. */
|
|
84
|
+
alias: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Any one value of a field within each group, of any type;
|
|
88
|
+
* {@link metricBuilders.any | `aggregation.any`}. Wow 9.0 and later. Neither a derived metric nor
|
|
89
|
+
* `having` may refer to it.
|
|
90
|
+
*/
|
|
91
|
+
export interface AnyAggregationMetric<FIELDS extends string = string> {
|
|
92
|
+
/** Aggregates only the rows that match. Wow 9.1 and later. */
|
|
93
|
+
filter?: FilterExpression<FIELDS>;
|
|
94
|
+
type: AggregationMetricType.ANY;
|
|
95
|
+
/** The field whose value is taken. */
|
|
96
|
+
field: QueryField<FIELDS>;
|
|
97
|
+
/** The name of the metric's column in the result rows. */
|
|
98
|
+
alias: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A field's value on the earliest (`FIRST`) or latest (`LAST`) record of
|
|
102
|
+
* each group, ordered by `orderBy`; {@link metricBuilders.first | `aggregation.first`} and
|
|
103
|
+
* {@link metricBuilders.last | `aggregation.last`}. Wow 9.2 and later.
|
|
104
|
+
*
|
|
105
|
+
* The value comes back in the field's own type, not as a number, and is
|
|
106
|
+
* `null` when no record of the group has both a value and an `orderBy`
|
|
107
|
+
* position. Without `orderBy` the server orders by the model's event time,
|
|
108
|
+
* the field the descriptor names as `analysis.firstLastOrderBy`. Records
|
|
109
|
+
* tied on `orderBy` may yield any one of their values. Like `ANY`, neither a
|
|
110
|
+
* derived metric nor `having` may refer to it.
|
|
111
|
+
*/
|
|
112
|
+
export interface EdgeAggregationMetric<FIELDS extends string = string> {
|
|
113
|
+
type: AggregationMetricType.FIRST | AggregationMetricType.LAST;
|
|
114
|
+
/** The single-valued field whose value is taken. */
|
|
115
|
+
field: QueryField<FIELDS>;
|
|
116
|
+
/**
|
|
117
|
+
* The single-valued, sortable field that orders the records; the model's
|
|
118
|
+
* event time when absent.
|
|
119
|
+
*/
|
|
120
|
+
orderBy?: QueryField<FIELDS>;
|
|
121
|
+
/** The name of the metric's column in the result rows. */
|
|
122
|
+
alias: string;
|
|
123
|
+
/** Aggregates only the rows that match. */
|
|
124
|
+
filter?: FilterExpression<FIELDS>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The number of distinct values of an expression;
|
|
128
|
+
* {@link metricBuilders.distinctCount | `aggregation.distinctCount`}. Wow 9.1 and later.
|
|
129
|
+
*/
|
|
130
|
+
export interface DistinctCountAggregationMetric<FIELDS extends string = string> {
|
|
131
|
+
type: AggregationMetricType.DISTINCT_COUNT;
|
|
132
|
+
/** The per-row value whose distinct values are counted. */
|
|
133
|
+
expression: AggregationExpression<FIELDS>;
|
|
134
|
+
/** The name of the metric's column in the result rows. */
|
|
135
|
+
alias: string;
|
|
136
|
+
/** Aggregates only the rows that match. */
|
|
137
|
+
filter?: FilterExpression<FIELDS>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A percentile of an expression; {@link metricBuilders.percentile | `aggregation.percentile`}. Wow 9.1 and
|
|
141
|
+
* later.
|
|
142
|
+
*/
|
|
143
|
+
export interface PercentileAggregationMetric<FIELDS extends string = string> {
|
|
144
|
+
type: AggregationMetricType.PERCENTILE;
|
|
145
|
+
/** The per-row value the percentile is taken over. */
|
|
146
|
+
expression: AggregationExpression<FIELDS>;
|
|
147
|
+
/** Which percentile, within (0, 100). */
|
|
148
|
+
percentile: number;
|
|
149
|
+
/** The name of the metric's column in the result rows. */
|
|
150
|
+
alias: string;
|
|
151
|
+
/** Aggregates only the rows that match. */
|
|
152
|
+
filter?: FilterExpression<FIELDS>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* One column an {@link AggregationQuery} computes for each group; a query
|
|
156
|
+
* takes 1 to `AGGREGATION_LIMITS.MAX_METRICS` of them.
|
|
157
|
+
*/
|
|
158
|
+
export type AggregationMetric<FIELDS extends string = string> = CountAggregationMetric<FIELDS> | NumericAggregationMetric<FIELDS> | AnyAggregationMetric<FIELDS> | DistinctCountAggregationMetric<FIELDS> | PercentileAggregationMetric<FIELDS> | DerivedAggregationMetric | EdgeAggregationMetric<FIELDS>;
|
|
159
|
+
/**
|
|
160
|
+
* The options every metric builder takes after its target and alias.
|
|
161
|
+
*/
|
|
162
|
+
export interface AggregationMetricOptions<FIELDS extends string = string> {
|
|
163
|
+
/** Counts only the rows that match; sent as the metric's `filter`. */
|
|
164
|
+
filter?: FilterExpression<FIELDS>;
|
|
165
|
+
}
|
|
166
|
+
/** The options of {@link metricBuilders.first | `aggregation.first`} and {@link metricBuilders.last | `aggregation.last`}. */
|
|
167
|
+
export interface EdgeAggregationOptions<FIELDS extends string = string> extends AggregationMetricOptions<FIELDS> {
|
|
168
|
+
/**
|
|
169
|
+
* The single-valued, sortable field that orders the records. Defaults to
|
|
170
|
+
* the model's event time, `analysis.firstLastOrderBy` in the descriptor.
|
|
171
|
+
*/
|
|
172
|
+
orderBy?: FIELDS;
|
|
173
|
+
}
|
|
174
|
+
/** The options of {@link metricBuilders.percentile | `aggregation.percentile`}. */
|
|
175
|
+
export interface PercentileAggregationOptions<FIELDS extends string = string> extends AggregationMetricOptions<FIELDS> {
|
|
176
|
+
/** Which percentile: finite and within (0, 100). */
|
|
177
|
+
percentile: number;
|
|
178
|
+
}
|
|
179
|
+
export declare function numeric<FIELDS extends string>(fn: AggregationFunction, expression: AggregationExpression<FIELDS>, alias: string, { filter: predicate }?: AggregationMetricOptions<FIELDS>): NumericAggregationMetric<FIELDS>;
|
|
180
|
+
/** Builds a `FIRST` or `LAST` metric; {@link metricBuilders.first | `aggregation.first`}. */
|
|
181
|
+
export declare function edge<FIELDS extends string>(type: AggregationMetricType.FIRST | AggregationMetricType.LAST, field: FIELDS, alias: string, { orderBy, filter: predicate }: EdgeAggregationOptions<FIELDS>): EdgeAggregationMetric<FIELDS>;
|
|
182
|
+
/** The builders of the metrics of an aggregation query: any, first, last, count, the numeric functions, distinct count and percentile. */
|
|
183
|
+
export declare const metricBuilders: {
|
|
184
|
+
/**
|
|
185
|
+
* Any one value of a field within each group, of any type.
|
|
186
|
+
* `{ type: 'any', field, alias, filter? }`.
|
|
187
|
+
*
|
|
188
|
+
* @throws TypeError when `field` or `alias` is invalid.
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* aggregation.any('state.customerName', 'customer');
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
any<FIELDS extends string>(field: FIELDS, alias: string, { filter: predicate }?: AggregationMetricOptions<FIELDS>): AnyAggregationMetric<FIELDS>;
|
|
195
|
+
/**
|
|
196
|
+
* The value of `field` on each group's earliest record by `orderBy`.
|
|
197
|
+
* `{ type: 'first', field, alias, orderBy?, filter? }`.
|
|
198
|
+
*
|
|
199
|
+
* The value comes back in the field's own type, or `null` when no record
|
|
200
|
+
* of the group has both a value and an `orderBy` position. Without
|
|
201
|
+
* `orderBy` the server orders by the model's event time, which the
|
|
202
|
+
* descriptor names as `analysis.firstLastOrderBy`. Neither a derived
|
|
203
|
+
* metric nor `having` may refer to it. Wow 9.2 and later.
|
|
204
|
+
*
|
|
205
|
+
* @throws TypeError when `field`, `orderBy` or `alias` is invalid.
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* aggregation.first('state.price', 'open', { orderBy: 'createTime' });
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
first<FIELDS extends string>(field: FIELDS, alias: string, options?: EdgeAggregationOptions<FIELDS>): EdgeAggregationMetric<FIELDS>;
|
|
212
|
+
/**
|
|
213
|
+
* The value of `field` on each group's latest record by `orderBy`.
|
|
214
|
+
* `{ type: 'last', field, alias, orderBy?, filter? }`. As
|
|
215
|
+
* {@link metricBuilders.first | `aggregation.first`}, from the other end.
|
|
216
|
+
*
|
|
217
|
+
* @throws TypeError when `field`, `orderBy` or `alias` is invalid.
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* aggregation.last('state.price', 'close', { orderBy: 'createTime' });
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
last<FIELDS extends string>(field: FIELDS, alias: string, options?: EdgeAggregationOptions<FIELDS>): EdgeAggregationMetric<FIELDS>;
|
|
224
|
+
/**
|
|
225
|
+
* The number of rows in each group. `{ type: 'count', alias, filter? }`.
|
|
226
|
+
*
|
|
227
|
+
* @param alias - The name of the metric column in the result rows.
|
|
228
|
+
* @param options.filter - Counts only the rows that match.
|
|
229
|
+
* @throws TypeError when `alias` is invalid.
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* aggregation.count('paid', { filter: filter.eq('state.status', 'PAID') });
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
count<FIELDS extends string = string>(alias: string, { filter: predicate }?: AggregationMetricOptions<FIELDS>): CountAggregationMetric<FIELDS>;
|
|
236
|
+
/**
|
|
237
|
+
* The sum of an expression. `{ type: 'numeric', function: 'sum',
|
|
238
|
+
* expression, alias, filter? }`.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* aggregation.sum(aggregation.field('state.amount'), 'revenue');
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
sum: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
246
|
+
/** The average of an expression; see {@link metricBuilders.sum | `aggregation.sum`}. */
|
|
247
|
+
avg: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
248
|
+
/** The least value of an expression; see {@link metricBuilders.sum | `aggregation.sum`}. */
|
|
249
|
+
min: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
250
|
+
/** The greatest value of an expression; see {@link metricBuilders.sum | `aggregation.sum`}. */
|
|
251
|
+
max: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
252
|
+
/** The standard deviation of an expression; see {@link metricBuilders.sum | `aggregation.sum`}. */
|
|
253
|
+
stddev: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
254
|
+
/** The variance of an expression; see {@link metricBuilders.sum | `aggregation.sum`}. */
|
|
255
|
+
variance: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
256
|
+
/**
|
|
257
|
+
* The number of distinct values of an expression.
|
|
258
|
+
* `{ type: 'distinct-count', expression, alias, filter? }`.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* aggregation.distinctCount(aggregation.field('ownerId'), 'customers');
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
distinctCount<FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, { filter: predicate }?: AggregationMetricOptions<FIELDS>): DistinctCountAggregationMetric<FIELDS>;
|
|
266
|
+
/**
|
|
267
|
+
* A percentile of an expression.
|
|
268
|
+
* `{ type: 'percentile', expression, percentile, alias, filter? }`.
|
|
269
|
+
*
|
|
270
|
+
* @param options.percentile - Which percentile, within (0, 100).
|
|
271
|
+
* @throws TypeError when `percentile` is not finite and within (0, 100), or
|
|
272
|
+
* `alias` is invalid.
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* aggregation.percentile(aggregation.field('latency'), 'p95', { percentile: 95 });
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
percentile<FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, { percentile, filter: predicate }: PercentileAggregationOptions<FIELDS>): PercentileAggregationMetric<FIELDS>;
|
|
279
|
+
};
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { FilterExpression, QueryField } from '../filter/index.js';
|
|
2
|
+
import { DerivedAggregationMetric } from './derived.js';
|
|
3
|
+
import { AggregationExpression } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The kind of an {@link AggregationMetric}, sent as its `type`. Wow 8.12
|
|
6
|
+
* knows `COUNT` and `NUMERIC`, Wow 9.0 adds `ANY`, and the other three need
|
|
7
|
+
* Wow 9.1.
|
|
8
|
+
*/
|
|
9
|
+
export declare enum AggregationMetricType {
|
|
10
|
+
/** The number of rows; {@link metricBuilders.count | `aggregation.count`}. */
|
|
11
|
+
COUNT = "count",
|
|
12
|
+
/**
|
|
13
|
+
* An {@link AggregationFunction} of an expression; {@link metricBuilders.sum | `aggregation.sum`}
|
|
14
|
+
* and its siblings.
|
|
15
|
+
*/
|
|
16
|
+
NUMERIC = "numeric",
|
|
17
|
+
/** Any one value of a field; {@link metricBuilders.any | `aggregation.any`}. Wow 9.0 and later. */
|
|
18
|
+
ANY = "any",
|
|
19
|
+
/**
|
|
20
|
+
* The number of distinct values; {@link metricBuilders.distinctCount | `aggregation.distinctCount`}. Wow 9.1
|
|
21
|
+
* and later.
|
|
22
|
+
*/
|
|
23
|
+
DISTINCT_COUNT = "distinct-count",
|
|
24
|
+
/**
|
|
25
|
+
* A percentile of an expression; {@link metricBuilders.percentile | `aggregation.percentile`}. Wow 9.1
|
|
26
|
+
* and later.
|
|
27
|
+
*/
|
|
28
|
+
PERCENTILE = "percentile",
|
|
29
|
+
/**
|
|
30
|
+
* Arithmetic over other metrics; {@link aggregation.derived}. Wow 9.1 and
|
|
31
|
+
* later.
|
|
32
|
+
*/
|
|
33
|
+
DERIVED = "derived",
|
|
34
|
+
/**
|
|
35
|
+
* A field's value on the group's earliest record; {@link metricBuilders.first | `aggregation.first`}.
|
|
36
|
+
* Wow 9.2 and later.
|
|
37
|
+
*/
|
|
38
|
+
FIRST = "first",
|
|
39
|
+
/**
|
|
40
|
+
* A field's value on the group's latest record; {@link metricBuilders.last | `aggregation.last`}.
|
|
41
|
+
* Wow 9.2 and later.
|
|
42
|
+
*/
|
|
43
|
+
LAST = "last"
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* What a `NUMERIC` metric computes over its expression; each has a builder,
|
|
47
|
+
* {@link metricBuilders.sum | `aggregation.sum`} through {@link metricBuilders.variance | `aggregation.variance`}.
|
|
48
|
+
*/
|
|
49
|
+
export declare enum AggregationFunction {
|
|
50
|
+
/** The sum */
|
|
51
|
+
SUM = "sum",
|
|
52
|
+
/** The average */
|
|
53
|
+
AVG = "avg",
|
|
54
|
+
/** The least value */
|
|
55
|
+
MIN = "min",
|
|
56
|
+
/** The greatest value */
|
|
57
|
+
MAX = "max",
|
|
58
|
+
/** The standard deviation */
|
|
59
|
+
STDDEV = "stddev",
|
|
60
|
+
/** The variance */
|
|
61
|
+
VARIANCE = "variance"
|
|
62
|
+
}
|
|
63
|
+
/** The number of rows in each group; {@link metricBuilders.count | `aggregation.count`}. */
|
|
64
|
+
export interface CountAggregationMetric<FIELDS extends string = string> {
|
|
65
|
+
/** Counts only the rows that match. Wow 9.1 and later. */
|
|
66
|
+
filter?: FilterExpression<FIELDS>;
|
|
67
|
+
type: AggregationMetricType.COUNT;
|
|
68
|
+
/** The name of the metric's column in the result rows. */
|
|
69
|
+
alias: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* An {@link AggregationFunction} of an expression; {@link metricBuilders.sum | `aggregation.sum`},
|
|
73
|
+
* `avg`, `min`, `max`, `stddev`, `variance`.
|
|
74
|
+
*/
|
|
75
|
+
export interface NumericAggregationMetric<FIELDS extends string = string> {
|
|
76
|
+
/** Aggregates only the rows that match. Wow 9.1 and later. */
|
|
77
|
+
filter?: FilterExpression<FIELDS>;
|
|
78
|
+
type: AggregationMetricType.NUMERIC;
|
|
79
|
+
/** What is computed. */
|
|
80
|
+
function: AggregationFunction;
|
|
81
|
+
/** The per-row value it is computed over. */
|
|
82
|
+
expression: AggregationExpression<FIELDS>;
|
|
83
|
+
/** The name of the metric's column in the result rows. */
|
|
84
|
+
alias: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Any one value of a field within each group, of any type;
|
|
88
|
+
* {@link metricBuilders.any | `aggregation.any`}. Wow 9.0 and later. Neither a derived metric nor
|
|
89
|
+
* `having` may refer to it.
|
|
90
|
+
*/
|
|
91
|
+
export interface AnyAggregationMetric<FIELDS extends string = string> {
|
|
92
|
+
/** Aggregates only the rows that match. Wow 9.1 and later. */
|
|
93
|
+
filter?: FilterExpression<FIELDS>;
|
|
94
|
+
type: AggregationMetricType.ANY;
|
|
95
|
+
/** The field whose value is taken. */
|
|
96
|
+
field: QueryField<FIELDS>;
|
|
97
|
+
/** The name of the metric's column in the result rows. */
|
|
98
|
+
alias: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A field's value on the earliest (`FIRST`) or latest (`LAST`) record of
|
|
102
|
+
* each group, ordered by `orderBy`; {@link metricBuilders.first | `aggregation.first`} and
|
|
103
|
+
* {@link metricBuilders.last | `aggregation.last`}. Wow 9.2 and later.
|
|
104
|
+
*
|
|
105
|
+
* The value comes back in the field's own type, not as a number, and is
|
|
106
|
+
* `null` when no record of the group has both a value and an `orderBy`
|
|
107
|
+
* position. Without `orderBy` the server orders by the model's event time,
|
|
108
|
+
* the field the descriptor names as `analysis.firstLastOrderBy`. Records
|
|
109
|
+
* tied on `orderBy` may yield any one of their values. Like `ANY`, neither a
|
|
110
|
+
* derived metric nor `having` may refer to it.
|
|
111
|
+
*/
|
|
112
|
+
export interface EdgeAggregationMetric<FIELDS extends string = string> {
|
|
113
|
+
type: AggregationMetricType.FIRST | AggregationMetricType.LAST;
|
|
114
|
+
/** The single-valued field whose value is taken. */
|
|
115
|
+
field: QueryField<FIELDS>;
|
|
116
|
+
/**
|
|
117
|
+
* The single-valued, sortable field that orders the records; the model's
|
|
118
|
+
* event time when absent.
|
|
119
|
+
*/
|
|
120
|
+
orderBy?: QueryField<FIELDS>;
|
|
121
|
+
/** The name of the metric's column in the result rows. */
|
|
122
|
+
alias: string;
|
|
123
|
+
/** Aggregates only the rows that match. */
|
|
124
|
+
filter?: FilterExpression<FIELDS>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The number of distinct values of an expression;
|
|
128
|
+
* {@link metricBuilders.distinctCount | `aggregation.distinctCount`}. Wow 9.1 and later.
|
|
129
|
+
*/
|
|
130
|
+
export interface DistinctCountAggregationMetric<FIELDS extends string = string> {
|
|
131
|
+
type: AggregationMetricType.DISTINCT_COUNT;
|
|
132
|
+
/** The per-row value whose distinct values are counted. */
|
|
133
|
+
expression: AggregationExpression<FIELDS>;
|
|
134
|
+
/** The name of the metric's column in the result rows. */
|
|
135
|
+
alias: string;
|
|
136
|
+
/** Aggregates only the rows that match. */
|
|
137
|
+
filter?: FilterExpression<FIELDS>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A percentile of an expression; {@link metricBuilders.percentile | `aggregation.percentile`}. Wow 9.1 and
|
|
141
|
+
* later.
|
|
142
|
+
*/
|
|
143
|
+
export interface PercentileAggregationMetric<FIELDS extends string = string> {
|
|
144
|
+
type: AggregationMetricType.PERCENTILE;
|
|
145
|
+
/** The per-row value the percentile is taken over. */
|
|
146
|
+
expression: AggregationExpression<FIELDS>;
|
|
147
|
+
/** Which percentile, within (0, 100). */
|
|
148
|
+
percentile: number;
|
|
149
|
+
/** The name of the metric's column in the result rows. */
|
|
150
|
+
alias: string;
|
|
151
|
+
/** Aggregates only the rows that match. */
|
|
152
|
+
filter?: FilterExpression<FIELDS>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* One column an {@link AggregationQuery} computes for each group; a query
|
|
156
|
+
* takes 1 to `AGGREGATION_LIMITS.MAX_METRICS` of them.
|
|
157
|
+
*/
|
|
158
|
+
export type AggregationMetric<FIELDS extends string = string> = CountAggregationMetric<FIELDS> | NumericAggregationMetric<FIELDS> | AnyAggregationMetric<FIELDS> | DistinctCountAggregationMetric<FIELDS> | PercentileAggregationMetric<FIELDS> | DerivedAggregationMetric | EdgeAggregationMetric<FIELDS>;
|
|
159
|
+
/**
|
|
160
|
+
* The options every metric builder takes after its target and alias.
|
|
161
|
+
*/
|
|
162
|
+
export interface AggregationMetricOptions<FIELDS extends string = string> {
|
|
163
|
+
/** Counts only the rows that match; sent as the metric's `filter`. */
|
|
164
|
+
filter?: FilterExpression<FIELDS>;
|
|
165
|
+
}
|
|
166
|
+
/** The options of {@link metricBuilders.first | `aggregation.first`} and {@link metricBuilders.last | `aggregation.last`}. */
|
|
167
|
+
export interface EdgeAggregationOptions<FIELDS extends string = string> extends AggregationMetricOptions<FIELDS> {
|
|
168
|
+
/**
|
|
169
|
+
* The single-valued, sortable field that orders the records. Defaults to
|
|
170
|
+
* the model's event time, `analysis.firstLastOrderBy` in the descriptor.
|
|
171
|
+
*/
|
|
172
|
+
orderBy?: FIELDS;
|
|
173
|
+
}
|
|
174
|
+
/** The options of {@link metricBuilders.percentile | `aggregation.percentile`}. */
|
|
175
|
+
export interface PercentileAggregationOptions<FIELDS extends string = string> extends AggregationMetricOptions<FIELDS> {
|
|
176
|
+
/** Which percentile: finite and within (0, 100). */
|
|
177
|
+
percentile: number;
|
|
178
|
+
}
|
|
179
|
+
export declare function numeric<FIELDS extends string>(fn: AggregationFunction, expression: AggregationExpression<FIELDS>, alias: string, { filter: predicate }?: AggregationMetricOptions<FIELDS>): NumericAggregationMetric<FIELDS>;
|
|
180
|
+
/** Builds a `FIRST` or `LAST` metric; {@link metricBuilders.first | `aggregation.first`}. */
|
|
181
|
+
export declare function edge<FIELDS extends string>(type: AggregationMetricType.FIRST | AggregationMetricType.LAST, field: FIELDS, alias: string, { orderBy, filter: predicate }: EdgeAggregationOptions<FIELDS>): EdgeAggregationMetric<FIELDS>;
|
|
182
|
+
/** The builders of the metrics of an aggregation query: any, first, last, count, the numeric functions, distinct count and percentile. */
|
|
183
|
+
export declare const metricBuilders: {
|
|
184
|
+
/**
|
|
185
|
+
* Any one value of a field within each group, of any type.
|
|
186
|
+
* `{ type: 'any', field, alias, filter? }`.
|
|
187
|
+
*
|
|
188
|
+
* @throws TypeError when `field` or `alias` is invalid.
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* aggregation.any('state.customerName', 'customer');
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
any<FIELDS extends string>(field: FIELDS, alias: string, { filter: predicate }?: AggregationMetricOptions<FIELDS>): AnyAggregationMetric<FIELDS>;
|
|
195
|
+
/**
|
|
196
|
+
* The value of `field` on each group's earliest record by `orderBy`.
|
|
197
|
+
* `{ type: 'first', field, alias, orderBy?, filter? }`.
|
|
198
|
+
*
|
|
199
|
+
* The value comes back in the field's own type, or `null` when no record
|
|
200
|
+
* of the group has both a value and an `orderBy` position. Without
|
|
201
|
+
* `orderBy` the server orders by the model's event time, which the
|
|
202
|
+
* descriptor names as `analysis.firstLastOrderBy`. Neither a derived
|
|
203
|
+
* metric nor `having` may refer to it. Wow 9.2 and later.
|
|
204
|
+
*
|
|
205
|
+
* @throws TypeError when `field`, `orderBy` or `alias` is invalid.
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* aggregation.first('state.price', 'open', { orderBy: 'createTime' });
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
first<FIELDS extends string>(field: FIELDS, alias: string, options?: EdgeAggregationOptions<FIELDS>): EdgeAggregationMetric<FIELDS>;
|
|
212
|
+
/**
|
|
213
|
+
* The value of `field` on each group's latest record by `orderBy`.
|
|
214
|
+
* `{ type: 'last', field, alias, orderBy?, filter? }`. As
|
|
215
|
+
* {@link metricBuilders.first | `aggregation.first`}, from the other end.
|
|
216
|
+
*
|
|
217
|
+
* @throws TypeError when `field`, `orderBy` or `alias` is invalid.
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* aggregation.last('state.price', 'close', { orderBy: 'createTime' });
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
last<FIELDS extends string>(field: FIELDS, alias: string, options?: EdgeAggregationOptions<FIELDS>): EdgeAggregationMetric<FIELDS>;
|
|
224
|
+
/**
|
|
225
|
+
* The number of rows in each group. `{ type: 'count', alias, filter? }`.
|
|
226
|
+
*
|
|
227
|
+
* @param alias - The name of the metric column in the result rows.
|
|
228
|
+
* @param options.filter - Counts only the rows that match.
|
|
229
|
+
* @throws TypeError when `alias` is invalid.
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* aggregation.count('paid', { filter: filter.eq('state.status', 'PAID') });
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
count<FIELDS extends string = string>(alias: string, { filter: predicate }?: AggregationMetricOptions<FIELDS>): CountAggregationMetric<FIELDS>;
|
|
236
|
+
/**
|
|
237
|
+
* The sum of an expression. `{ type: 'numeric', function: 'sum',
|
|
238
|
+
* expression, alias, filter? }`.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* aggregation.sum(aggregation.field('state.amount'), 'revenue');
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
sum: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
246
|
+
/** The average of an expression; see {@link metricBuilders.sum | `aggregation.sum`}. */
|
|
247
|
+
avg: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
248
|
+
/** The least value of an expression; see {@link metricBuilders.sum | `aggregation.sum`}. */
|
|
249
|
+
min: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
250
|
+
/** The greatest value of an expression; see {@link metricBuilders.sum | `aggregation.sum`}. */
|
|
251
|
+
max: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
252
|
+
/** The standard deviation of an expression; see {@link metricBuilders.sum | `aggregation.sum`}. */
|
|
253
|
+
stddev: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
254
|
+
/** The variance of an expression; see {@link metricBuilders.sum | `aggregation.sum`}. */
|
|
255
|
+
variance: <FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, options?: AggregationMetricOptions<FIELDS>) => NumericAggregationMetric<FIELDS>;
|
|
256
|
+
/**
|
|
257
|
+
* The number of distinct values of an expression.
|
|
258
|
+
* `{ type: 'distinct-count', expression, alias, filter? }`.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* aggregation.distinctCount(aggregation.field('ownerId'), 'customers');
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
distinctCount<FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, { filter: predicate }?: AggregationMetricOptions<FIELDS>): DistinctCountAggregationMetric<FIELDS>;
|
|
266
|
+
/**
|
|
267
|
+
* A percentile of an expression.
|
|
268
|
+
* `{ type: 'percentile', expression, percentile, alias, filter? }`.
|
|
269
|
+
*
|
|
270
|
+
* @param options.percentile - Which percentile, within (0, 100).
|
|
271
|
+
* @throws TypeError when `percentile` is not finite and within (0, 100), or
|
|
272
|
+
* `alias` is invalid.
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* aggregation.percentile(aggregation.field('latency'), 'p95', { percentile: 95 });
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
percentile<FIELDS extends string>(expression: AggregationExpression<FIELDS>, alias: string, { percentile, filter: predicate }: PercentileAggregationOptions<FIELDS>): PercentileAggregationMetric<FIELDS>;
|
|
279
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { aggregationAlias as e, aggregationField as t } from "./aliases.es.js";
|
|
2
|
+
// src/dsl/aggregation/metrics.ts
|
|
3
|
+
var n = /* @__PURE__ */ function(e) {
|
|
4
|
+
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;
|
|
5
|
+
}({}), r = /* @__PURE__ */ function(e) {
|
|
6
|
+
return e.SUM = "sum", e.AVG = "avg", e.MIN = "min", e.MAX = "max", e.STDDEV = "stddev", e.VARIANCE = "variance", e;
|
|
7
|
+
}({});
|
|
8
|
+
function i(t, n, r, { filter: i } = {}) {
|
|
9
|
+
return {
|
|
10
|
+
type: "numeric",
|
|
11
|
+
...i === void 0 ? {} : { filter: i },
|
|
12
|
+
function: t,
|
|
13
|
+
expression: n,
|
|
14
|
+
alias: e(r)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function a(n, r, i, { orderBy: a, filter: o }) {
|
|
18
|
+
return {
|
|
19
|
+
type: n,
|
|
20
|
+
field: t(r),
|
|
21
|
+
alias: e(i),
|
|
22
|
+
...a === void 0 ? {} : { orderBy: t(a) },
|
|
23
|
+
...o === void 0 ? {} : { filter: o }
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var o = {
|
|
27
|
+
any(n, r, { filter: i } = {}) {
|
|
28
|
+
return {
|
|
29
|
+
type: "any",
|
|
30
|
+
...i === void 0 ? {} : { filter: i },
|
|
31
|
+
field: t(n),
|
|
32
|
+
alias: e(r)
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
first(e, t, n = {}) {
|
|
36
|
+
return a("first", e, t, n);
|
|
37
|
+
},
|
|
38
|
+
last(e, t, n = {}) {
|
|
39
|
+
return a("last", e, t, n);
|
|
40
|
+
},
|
|
41
|
+
count(t, { filter: n } = {}) {
|
|
42
|
+
return {
|
|
43
|
+
type: "count",
|
|
44
|
+
...n === void 0 ? {} : { filter: n },
|
|
45
|
+
alias: e(t)
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
sum: (e, t, n) => i("sum", e, t, n),
|
|
49
|
+
avg: (e, t, n) => i("avg", e, t, n),
|
|
50
|
+
min: (e, t, n) => i("min", e, t, n),
|
|
51
|
+
max: (e, t, n) => i("max", e, t, n),
|
|
52
|
+
stddev: (e, t, n) => i("stddev", e, t, n),
|
|
53
|
+
variance: (e, t, n) => i("variance", e, t, n),
|
|
54
|
+
distinctCount(t, n, { filter: r } = {}) {
|
|
55
|
+
return {
|
|
56
|
+
type: "distinct-count",
|
|
57
|
+
expression: t,
|
|
58
|
+
alias: e(n),
|
|
59
|
+
...r === void 0 ? {} : { filter: r }
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
percentile(t, n, { percentile: r, filter: i }) {
|
|
63
|
+
if (!Number.isFinite(r) || r <= 0 || r >= 100) throw TypeError("percentile must be finite and within (0, 100).");
|
|
64
|
+
return {
|
|
65
|
+
type: "percentile",
|
|
66
|
+
expression: t,
|
|
67
|
+
percentile: r,
|
|
68
|
+
alias: e(n),
|
|
69
|
+
...i === void 0 ? {} : { filter: i }
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
export { r as AggregationFunction, n as AggregationMetricType, a as edge, o as metricBuilders, i as numeric };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=metrics.es.js.map
|