@ahoo-wang/wow-client 10.0.0-beta.1 → 10.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +4 -2
  2. package/README.zh-CN.md +1 -1
  3. package/dist/commands.cjs +1 -1
  4. package/dist/commands.cjs.map +1 -1
  5. package/dist/commands.d.cts +1 -8
  6. package/dist/commands.d.ts +1 -8
  7. package/dist/commands.es.js +45 -51
  8. package/dist/commands.es.js.map +1 -1
  9. package/dist/dsl/aggregation/admit.cjs +1 -1
  10. package/dist/dsl/aggregation/admit.cjs.map +1 -1
  11. package/dist/dsl/aggregation/admit.es.js +73 -69
  12. package/dist/dsl/aggregation/admit.es.js.map +1 -1
  13. package/dist/dsl/aggregation/aliases.cjs +2 -0
  14. package/dist/dsl/aggregation/aliases.cjs.map +1 -0
  15. package/dist/dsl/aggregation/aliases.d.cts +2 -0
  16. package/dist/dsl/aggregation/aliases.d.ts +2 -0
  17. package/dist/dsl/aggregation/aliases.es.js +13 -0
  18. package/dist/dsl/aggregation/aliases.es.js.map +1 -0
  19. package/dist/dsl/aggregation/builders.cjs +1 -1
  20. package/dist/dsl/aggregation/builders.cjs.map +1 -1
  21. package/dist/dsl/aggregation/builders.d.cts +17 -243
  22. package/dist/dsl/aggregation/builders.d.ts +17 -243
  23. package/dist/dsl/aggregation/builders.es.js +36 -171
  24. package/dist/dsl/aggregation/builders.es.js.map +1 -1
  25. package/dist/dsl/aggregation/derived.cjs +1 -1
  26. package/dist/dsl/aggregation/derived.cjs.map +1 -1
  27. package/dist/dsl/aggregation/derived.d.cts +123 -1
  28. package/dist/dsl/aggregation/derived.d.ts +123 -1
  29. package/dist/dsl/aggregation/derived.es.js +43 -28
  30. package/dist/dsl/aggregation/derived.es.js.map +1 -1
  31. package/dist/dsl/aggregation/groups.cjs +2 -0
  32. package/dist/dsl/aggregation/groups.cjs.map +1 -0
  33. package/dist/dsl/aggregation/groups.d.cts +325 -0
  34. package/dist/dsl/aggregation/groups.d.ts +325 -0
  35. package/dist/dsl/aggregation/groups.es.js +80 -0
  36. package/dist/dsl/aggregation/groups.es.js.map +1 -0
  37. package/dist/dsl/aggregation/having.cjs +1 -1
  38. package/dist/dsl/aggregation/having.cjs.map +1 -1
  39. package/dist/dsl/aggregation/having.d.cts +63 -1
  40. package/dist/dsl/aggregation/having.d.ts +63 -1
  41. package/dist/dsl/aggregation/having.es.js +33 -30
  42. package/dist/dsl/aggregation/having.es.js.map +1 -1
  43. package/dist/dsl/aggregation/index.d.cts +4 -2
  44. package/dist/dsl/aggregation/index.d.ts +4 -2
  45. package/dist/dsl/aggregation/metrics.cjs +2 -0
  46. package/dist/dsl/aggregation/metrics.cjs.map +1 -0
  47. package/dist/dsl/aggregation/metrics.d.cts +279 -0
  48. package/dist/dsl/aggregation/metrics.d.ts +279 -0
  49. package/dist/dsl/aggregation/metrics.es.js +75 -0
  50. package/dist/dsl/aggregation/metrics.es.js.map +1 -0
  51. package/dist/dsl/aggregation/types.cjs +1 -1
  52. package/dist/dsl/aggregation/types.cjs.map +1 -1
  53. package/dist/dsl/aggregation/types.d.cts +4 -524
  54. package/dist/dsl/aggregation/types.d.ts +4 -524
  55. package/dist/dsl/aggregation/types.es.js +5 -25
  56. package/dist/dsl/aggregation/types.es.js.map +1 -1
  57. package/dist/dsl/cursorQuery.cjs +1 -1
  58. package/dist/dsl/cursorQuery.cjs.map +1 -1
  59. package/dist/dsl/cursorQuery.d.cts +18 -7
  60. package/dist/dsl/cursorQuery.d.ts +18 -7
  61. package/dist/dsl/cursorQuery.es.js +13 -12
  62. package/dist/dsl/cursorQuery.es.js.map +1 -1
  63. package/dist/dsl/descriptor.cjs +1 -1
  64. package/dist/dsl/descriptor.cjs.map +1 -1
  65. package/dist/dsl/descriptor.d.cts +17 -379
  66. package/dist/dsl/descriptor.d.ts +17 -379
  67. package/dist/dsl/descriptor.es.js +4 -31
  68. package/dist/dsl/descriptor.es.js.map +1 -1
  69. package/dist/dsl/fieldDescriptor.cjs +2 -0
  70. package/dist/dsl/fieldDescriptor.cjs.map +1 -0
  71. package/dist/dsl/fieldDescriptor.d.cts +246 -0
  72. package/dist/dsl/fieldDescriptor.d.ts +246 -0
  73. package/dist/dsl/fieldDescriptor.es.js +24 -0
  74. package/dist/dsl/fieldDescriptor.es.js.map +1 -0
  75. package/dist/dsl/filter/builders.cjs +1 -1
  76. package/dist/dsl/filter/builders.cjs.map +1 -1
  77. package/dist/dsl/filter/builders.d.cts +7 -949
  78. package/dist/dsl/filter/builders.d.ts +7 -949
  79. package/dist/dsl/filter/builders.es.js +14 -285
  80. package/dist/dsl/filter/builders.es.js.map +1 -1
  81. package/dist/dsl/filter/expressionFilter.cjs +2 -0
  82. package/dist/dsl/filter/expressionFilter.cjs.map +1 -0
  83. package/dist/dsl/filter/expressionFilter.d.cts +35 -0
  84. package/dist/dsl/filter/expressionFilter.d.ts +35 -0
  85. package/dist/dsl/filter/expressionFilter.es.js +18 -0
  86. package/dist/dsl/filter/expressionFilter.es.js.map +1 -0
  87. package/dist/dsl/filter/fieldFilters.cjs +2 -0
  88. package/dist/dsl/filter/fieldFilters.cjs.map +1 -0
  89. package/dist/dsl/filter/fieldFilters.d.cts +297 -0
  90. package/dist/dsl/filter/fieldFilters.d.ts +297 -0
  91. package/dist/dsl/filter/fieldFilters.es.js +110 -0
  92. package/dist/dsl/filter/fieldFilters.es.js.map +1 -0
  93. package/dist/dsl/filter/index.d.cts +2 -1
  94. package/dist/dsl/filter/index.d.ts +2 -1
  95. package/dist/dsl/filter/logicalFilters.cjs +2 -0
  96. package/dist/dsl/filter/logicalFilters.cjs.map +1 -0
  97. package/dist/dsl/filter/logicalFilters.d.cts +109 -0
  98. package/dist/dsl/filter/logicalFilters.d.ts +109 -0
  99. package/dist/dsl/filter/logicalFilters.es.js +36 -0
  100. package/dist/dsl/filter/logicalFilters.es.js.map +1 -0
  101. package/dist/dsl/filter/metadataFilters.cjs +2 -0
  102. package/dist/dsl/filter/metadataFilters.cjs.map +1 -0
  103. package/dist/dsl/filter/metadataFilters.d.cts +132 -0
  104. package/dist/dsl/filter/metadataFilters.d.ts +132 -0
  105. package/dist/dsl/filter/metadataFilters.es.js +56 -0
  106. package/dist/dsl/filter/metadataFilters.es.js.map +1 -0
  107. package/dist/dsl/filter/operator.cjs +1 -1
  108. package/dist/dsl/filter/operator.cjs.map +1 -1
  109. package/dist/dsl/filter/operator.d.cts +11 -9
  110. package/dist/dsl/filter/operator.d.ts +11 -9
  111. package/dist/dsl/filter/operator.es.js +1 -1
  112. package/dist/dsl/filter/operator.es.js.map +1 -1
  113. package/dist/dsl/filter/searchFilter.cjs +2 -0
  114. package/dist/dsl/filter/searchFilter.cjs.map +1 -0
  115. package/dist/dsl/filter/searchFilter.d.cts +39 -0
  116. package/dist/dsl/filter/searchFilter.d.ts +39 -0
  117. package/dist/dsl/filter/searchFilter.es.js +19 -0
  118. package/dist/dsl/filter/searchFilter.es.js.map +1 -0
  119. package/dist/dsl/filter/timeFilters.cjs +2 -0
  120. package/dist/dsl/filter/timeFilters.cjs.map +1 -0
  121. package/dist/dsl/filter/timeFilters.d.cts +290 -0
  122. package/dist/dsl/filter/timeFilters.d.ts +290 -0
  123. package/dist/dsl/filter/timeFilters.es.js +89 -0
  124. package/dist/dsl/filter/timeFilters.es.js.map +1 -0
  125. package/dist/dsl/filter/types.d.cts +4 -14
  126. package/dist/dsl/filter/types.d.ts +4 -14
  127. package/dist/dsl/filter/validate.cjs +1 -1
  128. package/dist/dsl/filter/validate.cjs.map +1 -1
  129. package/dist/dsl/filter/validate.d.cts +2 -4
  130. package/dist/dsl/filter/validate.d.ts +2 -4
  131. package/dist/dsl/filter/validate.es.js +25 -31
  132. package/dist/dsl/filter/validate.es.js.map +1 -1
  133. package/dist/dsl/queryErrorCodes.cjs +1 -1
  134. package/dist/dsl/queryErrorCodes.cjs.map +1 -1
  135. package/dist/dsl/queryErrorCodes.d.cts +0 -2
  136. package/dist/dsl/queryErrorCodes.d.ts +0 -2
  137. package/dist/dsl/queryErrorCodes.es.js +0 -1
  138. package/dist/dsl/queryErrorCodes.es.js.map +1 -1
  139. package/dist/dsl/queryFilter.cjs +2 -0
  140. package/dist/dsl/queryFilter.cjs.map +1 -0
  141. package/dist/dsl/queryFilter.d.cts +3 -0
  142. package/dist/dsl/queryFilter.d.ts +3 -0
  143. package/dist/dsl/queryFilter.es.js +9 -0
  144. package/dist/dsl/queryFilter.es.js.map +1 -0
  145. package/dist/dsl/queryable.cjs +1 -1
  146. package/dist/dsl/queryable.cjs.map +1 -1
  147. package/dist/dsl/queryable.es.js +12 -16
  148. package/dist/dsl/queryable.es.js.map +1 -1
  149. package/dist/dsl/semanticTypes.cjs +2 -0
  150. package/dist/dsl/semanticTypes.cjs.map +1 -0
  151. package/dist/dsl/semanticTypes.d.cts +128 -0
  152. package/dist/dsl/semanticTypes.d.ts +128 -0
  153. package/dist/dsl/semanticTypes.es.js +13 -0
  154. package/dist/dsl/semanticTypes.es.js.map +1 -0
  155. package/dist/dsl.cjs +1 -1
  156. package/dist/dsl.d.cts +2 -0
  157. package/dist/dsl.d.ts +2 -0
  158. package/dist/dsl.es.js +14 -8
  159. package/dist/exactJson.cjs +2 -2
  160. package/dist/exactJson.cjs.map +1 -1
  161. package/dist/exactJson.d.cts +41 -16
  162. package/dist/exactJson.d.ts +41 -16
  163. package/dist/exactJson.es.js +104 -102
  164. package/dist/exactJson.es.js.map +1 -1
  165. package/dist/frameworkErrors.cjs.map +1 -1
  166. package/dist/frameworkErrors.d.cts +4 -4
  167. package/dist/frameworkErrors.d.ts +4 -4
  168. package/dist/frameworkErrors.es.js.map +1 -1
  169. package/dist/http.cjs +1 -1
  170. package/dist/http.cjs.map +1 -1
  171. package/dist/http.d.cts +29 -9
  172. package/dist/http.d.ts +29 -9
  173. package/dist/http.es.js +24 -19
  174. package/dist/http.es.js.map +1 -1
  175. package/dist/index.cjs +1 -1
  176. package/dist/index.d.cts +3 -3
  177. package/dist/index.d.ts +3 -3
  178. package/dist/index.es.js +12 -12
  179. package/dist/manifest.cjs +1 -1
  180. package/dist/manifest.cjs.map +1 -1
  181. package/dist/manifest.d.cts +24 -0
  182. package/dist/manifest.d.ts +24 -0
  183. package/dist/manifest.es.js +34 -6
  184. package/dist/manifest.es.js.map +1 -1
  185. package/dist/manifestTypes.d.cts +16 -1
  186. package/dist/manifestTypes.d.ts +16 -1
  187. package/dist/queries.cjs +1 -1
  188. package/dist/queries.cjs.map +1 -1
  189. package/dist/queries.d.cts +18 -8
  190. package/dist/queries.d.ts +18 -8
  191. package/dist/queries.es.js +46 -35
  192. package/dist/queries.es.js.map +1 -1
  193. package/dist/routes.cjs +1 -1
  194. package/dist/routes.cjs.map +1 -1
  195. package/dist/routes.d.cts +16 -3
  196. package/dist/routes.d.ts +16 -3
  197. package/dist/routes.es.js +24 -25
  198. package/dist/routes.es.js.map +1 -1
  199. package/dist/state.cjs +1 -1
  200. package/dist/state.cjs.map +1 -1
  201. package/dist/state.d.cts +21 -19
  202. package/dist/state.d.ts +21 -19
  203. package/dist/state.es.js +27 -22
  204. package/dist/state.es.js.map +1 -1
  205. package/dist/streams.cjs +1 -1
  206. package/dist/streams.cjs.map +1 -1
  207. package/dist/streams.d.cts +14 -7
  208. package/dist/streams.d.ts +14 -7
  209. package/dist/streams.es.js +65 -50
  210. package/dist/streams.es.js.map +1 -1
  211. package/dist/testing/wire.cjs +1 -1
  212. package/dist/testing/wire.cjs.map +1 -1
  213. package/dist/testing/wire.es.js +1 -1
  214. package/dist/testing/wire.es.js.map +1 -1
  215. package/dist/wait.cjs +1 -1
  216. package/dist/wait.cjs.map +1 -1
  217. package/dist/wait.d.cts +17 -4
  218. package/dist/wait.d.ts +17 -4
  219. package/dist/wait.es.js +36 -34
  220. package/dist/wait.es.js.map +1 -1
  221. package/dist/wire.cjs +1 -1
  222. package/dist/wire.cjs.map +1 -1
  223. package/dist/wire.d.cts +75 -31
  224. package/dist/wire.d.ts +75 -31
  225. package/dist/wire.es.js +1 -3
  226. package/dist/wire.es.js.map +1 -1
  227. package/package.json +5 -5
  228. package/dist/dsl/filter/datePattern.cjs +0 -2
  229. package/dist/dsl/filter/datePattern.cjs.map +0 -1
  230. package/dist/dsl/filter/datePattern.d.cts +0 -8
  231. package/dist/dsl/filter/datePattern.d.ts +0 -8
  232. package/dist/dsl/filter/datePattern.es.js +0 -96
  233. package/dist/dsl/filter/datePattern.es.js.map +0 -1
@@ -0,0 +1,325 @@
1
+ import { QueryField } from '../filter/index.cjs';
2
+ import { AggregationExpression } from './types.cjs';
3
+ /** The kind of an {@link AggregationGroup}, sent as its `type`. */
4
+ export declare enum AggregationGroupType {
5
+ /** One group per distinct value; {@link groupBuilders.terms | `aggregation.terms`}. */
6
+ TERMS = "terms",
7
+ /** Number buckets of equal width; {@link groupBuilders.histogram | `aggregation.histogram`}. */
8
+ HISTOGRAM = "histogram",
9
+ /** Calendar buckets of a time field; {@link groupBuilders.dateHistogram | `aggregation.dateHistogram`}. */
10
+ DATE_HISTOGRAM = "date-histogram",
11
+ /**
12
+ * One calendar part of a time field, such as the weekday or the hour;
13
+ * {@link groupBuilders.datePart | `aggregation.datePart`}. Wow 9.2 and later.
14
+ */
15
+ DATE_PART = "date-part"
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
+ }
27
+ /**
28
+ * The calendar unit of a `DATE_HISTOGRAM` bucket, cut in the group's
29
+ * `timeZone`.
30
+ */
31
+ export declare enum AggregationDateUnit {
32
+ YEAR = "year",
33
+ QUARTER = "quarter",
34
+ MONTH = "month",
35
+ WEEK = "week",
36
+ DAY = "day",
37
+ HOUR = "hour",
38
+ MINUTE = "minute",
39
+ SECOND = "second"
40
+ }
41
+ /**
42
+ * The calendar part a `DATE_PART` group takes of each instant, read in the
43
+ * group's `timeZone`. Its keys are integers from a fixed domain, so records
44
+ * from different days, weeks or years fall into one bucket.
45
+ */
46
+ export declare enum AggregationDatePart {
47
+ /** The ISO weekday: 1 is Monday, 7 is Sunday. */
48
+ DAY_OF_WEEK = "day-of-week",
49
+ /**
50
+ * The day of the month, 1 to 31; days 29 to 31 exist only in the months
51
+ * that have them.
52
+ */
53
+ DAY_OF_MONTH = "day-of-month",
54
+ /** The hour on the wall clock of the group's `timeZone`, 0 to 23. */
55
+ HOUR_OF_DAY = "hour-of-day",
56
+ /** The month of the year, 1 (January) to 12. */
57
+ MONTH_OF_YEAR = "month-of-year"
58
+ }
59
+ /** What every {@link AggregationGroup} has. */
60
+ interface AggregationGroupBase<FIELDS extends string = string> {
61
+ /** The field the rows are grouped by. */
62
+ field: QueryField<FIELDS>;
63
+ /** The name of the group's column in the result rows. */
64
+ alias: string;
65
+ /**
66
+ * What `field` is relative to when the query expands elements: the
67
+ * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
68
+ * A `ROOT` group names a field, never an expression. Wow 9.9 and later,
69
+ * where `analysis.rootGroups` is `true`.
70
+ */
71
+ scope?: AggregationGroupScope;
72
+ }
73
+ /**
74
+ * What a TERMS or HISTOGRAM group groups by: a field, or a computed
75
+ * expression in its place (Wow 9.2 and later), never both. An expression
76
+ * input is an expensive computation the server admits only where
77
+ * `analysis.expressions` is `true`.
78
+ */
79
+ export type AggregationGroupInput<FIELDS extends string = string> = {
80
+ /** The field the rows are grouped by. */
81
+ field: QueryField<FIELDS>;
82
+ expression?: undefined;
83
+ } | {
84
+ field?: undefined;
85
+ /** The per-row value the rows are grouped by, such as a `DATE_DIFF`. */
86
+ expression: AggregationExpression<FIELDS>;
87
+ };
88
+ /**
89
+ * One group per distinct value of a field, or of an expression;
90
+ * {@link groupBuilders.terms | `aggregation.terms`}. `missingKey` needs a field.
91
+ */
92
+ export type TermsAggregationGroup<FIELDS extends string = string> = {
93
+ type: AggregationGroupType.TERMS;
94
+ /** The name of the group's column in the result rows. */
95
+ alias: string;
96
+ /** The key the rows without a value are grouped under. Wow 9.1 and later. */
97
+ missingKey?: string;
98
+ /**
99
+ * What `field` is relative to when the query expands elements: the
100
+ * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
101
+ * A `ROOT` group names a field, never an expression. Wow 9.9 and later,
102
+ * where `analysis.rootGroups` is `true`.
103
+ */
104
+ scope?: AggregationGroupScope;
105
+ } & AggregationGroupInput<FIELDS>;
106
+ /**
107
+ * Buckets of equal width over a number field, or over an expression;
108
+ * {@link groupBuilders.histogram | `aggregation.histogram`}.
109
+ */
110
+ export type HistogramAggregationGroup<FIELDS extends string = string> = {
111
+ type: AggregationGroupType.HISTOGRAM;
112
+ /** The name of the group's column in the result rows. */
113
+ alias: string;
114
+ /** The width of each bucket, greater than 0. */
115
+ interval: number;
116
+ /**
117
+ * What `field` is relative to when the query expands elements: the
118
+ * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
119
+ * A `ROOT` group names a field, never an expression. Wow 9.9 and later,
120
+ * where `analysis.rootGroups` is `true`.
121
+ */
122
+ scope?: AggregationGroupScope;
123
+ } & AggregationGroupInput<FIELDS>;
124
+ /**
125
+ * Calendar buckets over a time field in epoch milliseconds;
126
+ * {@link groupBuilders.dateHistogram | `aggregation.dateHistogram`}.
127
+ */
128
+ export interface DateHistogramAggregationGroup<FIELDS extends string = string> extends AggregationGroupBase<FIELDS> {
129
+ type: AggregationGroupType.DATE_HISTOGRAM;
130
+ /** The calendar unit of each bucket. */
131
+ unit: AggregationDateUnit;
132
+ /** The IANA zone the buckets are cut in; `UTC` when absent. */
133
+ timeZone?: string;
134
+ /**
135
+ * Whether the server fills in the empty buckets of the range. Wow 9.1 and
136
+ * later, and only when this is the query's only group.
137
+ */
138
+ dense?: boolean;
139
+ }
140
+ /**
141
+ * One calendar part of a time field in epoch milliseconds, such as the
142
+ * weekday or the hour; {@link groupBuilders.datePart | `aggregation.datePart`}. Its keys in the result
143
+ * rows are integers from the part's domain, such as 1 (Monday) to 7 (Sunday)
144
+ * for `DAY_OF_WEEK`. Wow 9.2 and later.
145
+ */
146
+ export interface DatePartAggregationGroup<FIELDS extends string = string> extends AggregationGroupBase<FIELDS> {
147
+ type: AggregationGroupType.DATE_PART;
148
+ /** The calendar part each row is grouped by. */
149
+ part: AggregationDatePart;
150
+ /** The IANA zone the part is read in; `UTC` when absent. */
151
+ timeZone?: string;
152
+ /**
153
+ * Whether the server returns every key of the part's domain, filling a
154
+ * key with no records with each metric's empty value. Only when this is
155
+ * the query's only group.
156
+ */
157
+ dense?: boolean;
158
+ }
159
+ /**
160
+ * One dimension of an {@link AggregationQuery}'s `groupBy`: each result row
161
+ * is one combination of the groups' keys.
162
+ */
163
+ export type AggregationGroup<FIELDS extends string = string> = TermsAggregationGroup<FIELDS> | HistogramAggregationGroup<FIELDS> | DateHistogramAggregationGroup<FIELDS> | DatePartAggregationGroup<FIELDS>;
164
+ /** The option every group builder takes. */
165
+ export interface AggregationGroupScopeOptions {
166
+ /**
167
+ * What the field is relative to when the query expands elements; the
168
+ * innermost element when absent. `ROOT` needs a field input. Wow 9.9 and
169
+ * later.
170
+ */
171
+ scope?: AggregationGroupScope;
172
+ }
173
+ /** The options of {@link groupBuilders.terms | `aggregation.terms`}. */
174
+ export interface TermsAggregationOptions extends AggregationGroupScopeOptions {
175
+ /** The key rows without a value are grouped under; must not be blank. */
176
+ missingKey?: string;
177
+ }
178
+ /** The options of {@link groupBuilders.histogram | `aggregation.histogram`}. */
179
+ export interface HistogramAggregationOptions extends AggregationGroupScopeOptions {
180
+ /** The width of each bucket: finite and greater than 0. */
181
+ interval: number;
182
+ }
183
+ /** The options of {@link groupBuilders.dateHistogram | `aggregation.dateHistogram`}. */
184
+ export interface DateHistogramAggregationOptions extends AggregationGroupScopeOptions {
185
+ /** The calendar unit of each bucket. */
186
+ unit: AggregationDateUnit;
187
+ /** The zone the buckets are cut in, an IANA id. Sent only when set; the server reads none as `UTC`. */
188
+ timeZone?: string;
189
+ /**
190
+ * Whether the server fills in the empty buckets of the range. Only when
191
+ * this is the only group.
192
+ */
193
+ dense?: boolean;
194
+ }
195
+ /** The options of {@link groupBuilders.datePart | `aggregation.datePart`}. */
196
+ export interface DatePartAggregationOptions extends AggregationGroupScopeOptions {
197
+ /** The calendar part each row is grouped by. */
198
+ part: AggregationDatePart;
199
+ /** The zone the part is read in, an IANA id. Sent only when set; the server reads none as `UTC`. */
200
+ timeZone?: string;
201
+ /**
202
+ * Whether the server returns every key of the part's domain, the empty
203
+ * ones filled in. Only when this is the only group.
204
+ */
205
+ dense?: boolean;
206
+ }
207
+ /**
208
+ * The input of a TERMS or HISTOGRAM group: a field path, or an expression in
209
+ * its place, never both, as Wow's `requireGroupInput` has it.
210
+ */
211
+ export declare function groupInput<FIELDS extends string>(input: FIELDS | AggregationExpression<FIELDS>, type: string): AggregationGroupInput<FIELDS>;
212
+ /** A group's `scope`, sent only when given; `ROOT` needs a field input. */
213
+ export declare function groupScope(scope: AggregationGroupScope | undefined, type: string, source: {
214
+ expression?: unknown;
215
+ }): {
216
+ scope?: AggregationGroupScope;
217
+ };
218
+ /** The builders of the groups of an aggregation query: terms, histograms, date histograms and date parts. */
219
+ export declare const groupBuilders: {
220
+ /**
221
+ * Groups by each distinct value of a field, or of a computed expression.
222
+ * `{ type: 'terms', field, alias, missingKey? }`, or
223
+ * `{ type: 'terms', expression, alias }`.
224
+ *
225
+ * @param input - The field to group by, or an expression in its place
226
+ * (Wow 9.2 and later, an expensive computation).
227
+ * @param alias - The name of the group column in the result rows.
228
+ * @param options.missingKey - The key of the rows without a value; only
229
+ * with a field.
230
+ * @param options.scope - What the field is relative to when the query
231
+ * expands elements: `ROOT` groups the elements by a field of their root
232
+ * record. Wow 9.9 and later.
233
+ * @throws TypeError when `input` or `alias` is invalid, `missingKey` is
234
+ * blank, or `missingKey` is given with an expression.
235
+ * @example
236
+ * ```typescript
237
+ * aggregation.terms('state.status', 'status', { missingKey: 'NONE' });
238
+ * aggregation.terms(
239
+ * aggregation.dateDiff('state.paidAt', 'state.shippedAt', DateDiffUnit.DAY),
240
+ * 'daysToShip',
241
+ * );
242
+ * ```
243
+ */
244
+ terms<FIELDS extends string>(input: FIELDS | AggregationExpression<FIELDS>, alias: string, { missingKey, scope }?: TermsAggregationOptions): TermsAggregationGroup<FIELDS>;
245
+ /**
246
+ * Groups a number field, or a computed expression, into buckets of equal
247
+ * width. `{ type: 'histogram', field | expression, interval, alias }`.
248
+ *
249
+ * @param input - The number field to bucket, or an expression in its
250
+ * place (Wow 9.2 and later, an expensive computation).
251
+ * @param alias - The name of the bucket column in the result rows.
252
+ * @param options.interval - The bucket width.
253
+ * @param options.scope - What the field is relative to when the query
254
+ * expands elements: `ROOT` groups the elements by a field of their root
255
+ * record. Wow 9.9 and later.
256
+ * @throws TypeError when `interval` is not finite and greater than 0, or
257
+ * `field` or `alias` is invalid.
258
+ * @example
259
+ * ```typescript
260
+ * aggregation.histogram('state.amount', 'amountBand', { interval: 100 });
261
+ * ```
262
+ */
263
+ histogram<FIELDS extends string>(input: FIELDS | AggregationExpression<FIELDS>, alias: string, { interval, scope }: HistogramAggregationOptions): HistogramAggregationGroup<FIELDS>;
264
+ /**
265
+ * Groups a time field into calendar buckets.
266
+ * `{ type: 'date-histogram', field, unit, alias, timeZone?, dense? }`.
267
+ *
268
+ * @param field - The time field (epoch milliseconds) to bucket.
269
+ * @param alias - The name of the bucket column in the result rows.
270
+ * @param options.unit - The calendar unit of a bucket.
271
+ * @param options.timeZone - The zone buckets are cut in. Sent only when
272
+ * set; the server reads none as `UTC`.
273
+ * @param options.dense - Whether the empty buckets of the range are filled
274
+ * in.
275
+ * @param options.scope - What the field is relative to when the query
276
+ * expands elements: `ROOT` groups the elements by a field of their root
277
+ * record. Wow 9.9 and later.
278
+ * @throws TypeError when `unit` is not an `AggregationDateUnit`,
279
+ * `timeZone` is blank, `dense` is not a boolean, or `field` or `alias` is
280
+ * invalid.
281
+ * @example
282
+ * ```typescript
283
+ * aggregation.dateHistogram('createTime', 'day', {
284
+ * unit: AggregationDateUnit.DAY,
285
+ * timeZone: 'Asia/Shanghai',
286
+ * });
287
+ * ```
288
+ */
289
+ dateHistogram<FIELDS extends string>(field: FIELDS, alias: string, { unit, timeZone, dense, scope }: DateHistogramAggregationOptions): DateHistogramAggregationGroup<FIELDS>;
290
+ /**
291
+ * Groups a time field by one calendar part of each instant, such as the
292
+ * weekday or the hour, so records from different days share a bucket.
293
+ * `{ type: 'date-part', field, part, alias, timeZone?, dense? }`.
294
+ *
295
+ * The group's keys in the result rows are integers: `DAY_OF_WEEK` is the
296
+ * ISO weekday, 1 (Monday) to 7 (Sunday); `DAY_OF_MONTH` 1 to 31;
297
+ * `HOUR_OF_DAY` 0 to 23 on the wall clock of `timeZone`; `MONTH_OF_YEAR`
298
+ * 1 to 12. With `dense`, every key of that domain comes back, those
299
+ * without records carrying each metric's empty value; `dense` needs the
300
+ * group to be the query's only one. Wow 9.2 and later.
301
+ *
302
+ * @param field - The time field (epoch milliseconds) to read the part of.
303
+ * @param alias - The name of the part column in the result rows.
304
+ * @param options.part - The calendar part to group by.
305
+ * @param options.timeZone - The zone the part is read in. Sent only when
306
+ * set; the server reads none as `UTC`.
307
+ * @param options.dense - Whether every key of the part's domain is
308
+ * returned.
309
+ * @param options.scope - What the field is relative to when the query
310
+ * expands elements: `ROOT` groups the elements by a field of their root
311
+ * record. Wow 9.9 and later.
312
+ * @throws TypeError when `part` is not an `AggregationDatePart`,
313
+ * `timeZone` is blank, `dense` is not a boolean, or `field` or `alias` is
314
+ * invalid.
315
+ * @example
316
+ * ```typescript
317
+ * aggregation.datePart('createTime', 'weekday', {
318
+ * part: AggregationDatePart.DAY_OF_WEEK,
319
+ * timeZone: 'Asia/Shanghai',
320
+ * });
321
+ * ```
322
+ */
323
+ datePart<FIELDS extends string>(field: FIELDS, alias: string, { part, timeZone, dense, scope }: DatePartAggregationOptions): DatePartAggregationGroup<FIELDS>;
324
+ };
325
+ export {};
@@ -0,0 +1,325 @@
1
+ import { QueryField } from '../filter/index.js';
2
+ import { AggregationExpression } from './types.js';
3
+ /** The kind of an {@link AggregationGroup}, sent as its `type`. */
4
+ export declare enum AggregationGroupType {
5
+ /** One group per distinct value; {@link groupBuilders.terms | `aggregation.terms`}. */
6
+ TERMS = "terms",
7
+ /** Number buckets of equal width; {@link groupBuilders.histogram | `aggregation.histogram`}. */
8
+ HISTOGRAM = "histogram",
9
+ /** Calendar buckets of a time field; {@link groupBuilders.dateHistogram | `aggregation.dateHistogram`}. */
10
+ DATE_HISTOGRAM = "date-histogram",
11
+ /**
12
+ * One calendar part of a time field, such as the weekday or the hour;
13
+ * {@link groupBuilders.datePart | `aggregation.datePart`}. Wow 9.2 and later.
14
+ */
15
+ DATE_PART = "date-part"
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
+ }
27
+ /**
28
+ * The calendar unit of a `DATE_HISTOGRAM` bucket, cut in the group's
29
+ * `timeZone`.
30
+ */
31
+ export declare enum AggregationDateUnit {
32
+ YEAR = "year",
33
+ QUARTER = "quarter",
34
+ MONTH = "month",
35
+ WEEK = "week",
36
+ DAY = "day",
37
+ HOUR = "hour",
38
+ MINUTE = "minute",
39
+ SECOND = "second"
40
+ }
41
+ /**
42
+ * The calendar part a `DATE_PART` group takes of each instant, read in the
43
+ * group's `timeZone`. Its keys are integers from a fixed domain, so records
44
+ * from different days, weeks or years fall into one bucket.
45
+ */
46
+ export declare enum AggregationDatePart {
47
+ /** The ISO weekday: 1 is Monday, 7 is Sunday. */
48
+ DAY_OF_WEEK = "day-of-week",
49
+ /**
50
+ * The day of the month, 1 to 31; days 29 to 31 exist only in the months
51
+ * that have them.
52
+ */
53
+ DAY_OF_MONTH = "day-of-month",
54
+ /** The hour on the wall clock of the group's `timeZone`, 0 to 23. */
55
+ HOUR_OF_DAY = "hour-of-day",
56
+ /** The month of the year, 1 (January) to 12. */
57
+ MONTH_OF_YEAR = "month-of-year"
58
+ }
59
+ /** What every {@link AggregationGroup} has. */
60
+ interface AggregationGroupBase<FIELDS extends string = string> {
61
+ /** The field the rows are grouped by. */
62
+ field: QueryField<FIELDS>;
63
+ /** The name of the group's column in the result rows. */
64
+ alias: string;
65
+ /**
66
+ * What `field` is relative to when the query expands elements: the
67
+ * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
68
+ * A `ROOT` group names a field, never an expression. Wow 9.9 and later,
69
+ * where `analysis.rootGroups` is `true`.
70
+ */
71
+ scope?: AggregationGroupScope;
72
+ }
73
+ /**
74
+ * What a TERMS or HISTOGRAM group groups by: a field, or a computed
75
+ * expression in its place (Wow 9.2 and later), never both. An expression
76
+ * input is an expensive computation the server admits only where
77
+ * `analysis.expressions` is `true`.
78
+ */
79
+ export type AggregationGroupInput<FIELDS extends string = string> = {
80
+ /** The field the rows are grouped by. */
81
+ field: QueryField<FIELDS>;
82
+ expression?: undefined;
83
+ } | {
84
+ field?: undefined;
85
+ /** The per-row value the rows are grouped by, such as a `DATE_DIFF`. */
86
+ expression: AggregationExpression<FIELDS>;
87
+ };
88
+ /**
89
+ * One group per distinct value of a field, or of an expression;
90
+ * {@link groupBuilders.terms | `aggregation.terms`}. `missingKey` needs a field.
91
+ */
92
+ export type TermsAggregationGroup<FIELDS extends string = string> = {
93
+ type: AggregationGroupType.TERMS;
94
+ /** The name of the group's column in the result rows. */
95
+ alias: string;
96
+ /** The key the rows without a value are grouped under. Wow 9.1 and later. */
97
+ missingKey?: string;
98
+ /**
99
+ * What `field` is relative to when the query expands elements: the
100
+ * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
101
+ * A `ROOT` group names a field, never an expression. Wow 9.9 and later,
102
+ * where `analysis.rootGroups` is `true`.
103
+ */
104
+ scope?: AggregationGroupScope;
105
+ } & AggregationGroupInput<FIELDS>;
106
+ /**
107
+ * Buckets of equal width over a number field, or over an expression;
108
+ * {@link groupBuilders.histogram | `aggregation.histogram`}.
109
+ */
110
+ export type HistogramAggregationGroup<FIELDS extends string = string> = {
111
+ type: AggregationGroupType.HISTOGRAM;
112
+ /** The name of the group's column in the result rows. */
113
+ alias: string;
114
+ /** The width of each bucket, greater than 0. */
115
+ interval: number;
116
+ /**
117
+ * What `field` is relative to when the query expands elements: the
118
+ * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).
119
+ * A `ROOT` group names a field, never an expression. Wow 9.9 and later,
120
+ * where `analysis.rootGroups` is `true`.
121
+ */
122
+ scope?: AggregationGroupScope;
123
+ } & AggregationGroupInput<FIELDS>;
124
+ /**
125
+ * Calendar buckets over a time field in epoch milliseconds;
126
+ * {@link groupBuilders.dateHistogram | `aggregation.dateHistogram`}.
127
+ */
128
+ export interface DateHistogramAggregationGroup<FIELDS extends string = string> extends AggregationGroupBase<FIELDS> {
129
+ type: AggregationGroupType.DATE_HISTOGRAM;
130
+ /** The calendar unit of each bucket. */
131
+ unit: AggregationDateUnit;
132
+ /** The IANA zone the buckets are cut in; `UTC` when absent. */
133
+ timeZone?: string;
134
+ /**
135
+ * Whether the server fills in the empty buckets of the range. Wow 9.1 and
136
+ * later, and only when this is the query's only group.
137
+ */
138
+ dense?: boolean;
139
+ }
140
+ /**
141
+ * One calendar part of a time field in epoch milliseconds, such as the
142
+ * weekday or the hour; {@link groupBuilders.datePart | `aggregation.datePart`}. Its keys in the result
143
+ * rows are integers from the part's domain, such as 1 (Monday) to 7 (Sunday)
144
+ * for `DAY_OF_WEEK`. Wow 9.2 and later.
145
+ */
146
+ export interface DatePartAggregationGroup<FIELDS extends string = string> extends AggregationGroupBase<FIELDS> {
147
+ type: AggregationGroupType.DATE_PART;
148
+ /** The calendar part each row is grouped by. */
149
+ part: AggregationDatePart;
150
+ /** The IANA zone the part is read in; `UTC` when absent. */
151
+ timeZone?: string;
152
+ /**
153
+ * Whether the server returns every key of the part's domain, filling a
154
+ * key with no records with each metric's empty value. Only when this is
155
+ * the query's only group.
156
+ */
157
+ dense?: boolean;
158
+ }
159
+ /**
160
+ * One dimension of an {@link AggregationQuery}'s `groupBy`: each result row
161
+ * is one combination of the groups' keys.
162
+ */
163
+ export type AggregationGroup<FIELDS extends string = string> = TermsAggregationGroup<FIELDS> | HistogramAggregationGroup<FIELDS> | DateHistogramAggregationGroup<FIELDS> | DatePartAggregationGroup<FIELDS>;
164
+ /** The option every group builder takes. */
165
+ export interface AggregationGroupScopeOptions {
166
+ /**
167
+ * What the field is relative to when the query expands elements; the
168
+ * innermost element when absent. `ROOT` needs a field input. Wow 9.9 and
169
+ * later.
170
+ */
171
+ scope?: AggregationGroupScope;
172
+ }
173
+ /** The options of {@link groupBuilders.terms | `aggregation.terms`}. */
174
+ export interface TermsAggregationOptions extends AggregationGroupScopeOptions {
175
+ /** The key rows without a value are grouped under; must not be blank. */
176
+ missingKey?: string;
177
+ }
178
+ /** The options of {@link groupBuilders.histogram | `aggregation.histogram`}. */
179
+ export interface HistogramAggregationOptions extends AggregationGroupScopeOptions {
180
+ /** The width of each bucket: finite and greater than 0. */
181
+ interval: number;
182
+ }
183
+ /** The options of {@link groupBuilders.dateHistogram | `aggregation.dateHistogram`}. */
184
+ export interface DateHistogramAggregationOptions extends AggregationGroupScopeOptions {
185
+ /** The calendar unit of each bucket. */
186
+ unit: AggregationDateUnit;
187
+ /** The zone the buckets are cut in, an IANA id. Sent only when set; the server reads none as `UTC`. */
188
+ timeZone?: string;
189
+ /**
190
+ * Whether the server fills in the empty buckets of the range. Only when
191
+ * this is the only group.
192
+ */
193
+ dense?: boolean;
194
+ }
195
+ /** The options of {@link groupBuilders.datePart | `aggregation.datePart`}. */
196
+ export interface DatePartAggregationOptions extends AggregationGroupScopeOptions {
197
+ /** The calendar part each row is grouped by. */
198
+ part: AggregationDatePart;
199
+ /** The zone the part is read in, an IANA id. Sent only when set; the server reads none as `UTC`. */
200
+ timeZone?: string;
201
+ /**
202
+ * Whether the server returns every key of the part's domain, the empty
203
+ * ones filled in. Only when this is the only group.
204
+ */
205
+ dense?: boolean;
206
+ }
207
+ /**
208
+ * The input of a TERMS or HISTOGRAM group: a field path, or an expression in
209
+ * its place, never both, as Wow's `requireGroupInput` has it.
210
+ */
211
+ export declare function groupInput<FIELDS extends string>(input: FIELDS | AggregationExpression<FIELDS>, type: string): AggregationGroupInput<FIELDS>;
212
+ /** A group's `scope`, sent only when given; `ROOT` needs a field input. */
213
+ export declare function groupScope(scope: AggregationGroupScope | undefined, type: string, source: {
214
+ expression?: unknown;
215
+ }): {
216
+ scope?: AggregationGroupScope;
217
+ };
218
+ /** The builders of the groups of an aggregation query: terms, histograms, date histograms and date parts. */
219
+ export declare const groupBuilders: {
220
+ /**
221
+ * Groups by each distinct value of a field, or of a computed expression.
222
+ * `{ type: 'terms', field, alias, missingKey? }`, or
223
+ * `{ type: 'terms', expression, alias }`.
224
+ *
225
+ * @param input - The field to group by, or an expression in its place
226
+ * (Wow 9.2 and later, an expensive computation).
227
+ * @param alias - The name of the group column in the result rows.
228
+ * @param options.missingKey - The key of the rows without a value; only
229
+ * with a field.
230
+ * @param options.scope - What the field is relative to when the query
231
+ * expands elements: `ROOT` groups the elements by a field of their root
232
+ * record. Wow 9.9 and later.
233
+ * @throws TypeError when `input` or `alias` is invalid, `missingKey` is
234
+ * blank, or `missingKey` is given with an expression.
235
+ * @example
236
+ * ```typescript
237
+ * aggregation.terms('state.status', 'status', { missingKey: 'NONE' });
238
+ * aggregation.terms(
239
+ * aggregation.dateDiff('state.paidAt', 'state.shippedAt', DateDiffUnit.DAY),
240
+ * 'daysToShip',
241
+ * );
242
+ * ```
243
+ */
244
+ terms<FIELDS extends string>(input: FIELDS | AggregationExpression<FIELDS>, alias: string, { missingKey, scope }?: TermsAggregationOptions): TermsAggregationGroup<FIELDS>;
245
+ /**
246
+ * Groups a number field, or a computed expression, into buckets of equal
247
+ * width. `{ type: 'histogram', field | expression, interval, alias }`.
248
+ *
249
+ * @param input - The number field to bucket, or an expression in its
250
+ * place (Wow 9.2 and later, an expensive computation).
251
+ * @param alias - The name of the bucket column in the result rows.
252
+ * @param options.interval - The bucket width.
253
+ * @param options.scope - What the field is relative to when the query
254
+ * expands elements: `ROOT` groups the elements by a field of their root
255
+ * record. Wow 9.9 and later.
256
+ * @throws TypeError when `interval` is not finite and greater than 0, or
257
+ * `field` or `alias` is invalid.
258
+ * @example
259
+ * ```typescript
260
+ * aggregation.histogram('state.amount', 'amountBand', { interval: 100 });
261
+ * ```
262
+ */
263
+ histogram<FIELDS extends string>(input: FIELDS | AggregationExpression<FIELDS>, alias: string, { interval, scope }: HistogramAggregationOptions): HistogramAggregationGroup<FIELDS>;
264
+ /**
265
+ * Groups a time field into calendar buckets.
266
+ * `{ type: 'date-histogram', field, unit, alias, timeZone?, dense? }`.
267
+ *
268
+ * @param field - The time field (epoch milliseconds) to bucket.
269
+ * @param alias - The name of the bucket column in the result rows.
270
+ * @param options.unit - The calendar unit of a bucket.
271
+ * @param options.timeZone - The zone buckets are cut in. Sent only when
272
+ * set; the server reads none as `UTC`.
273
+ * @param options.dense - Whether the empty buckets of the range are filled
274
+ * in.
275
+ * @param options.scope - What the field is relative to when the query
276
+ * expands elements: `ROOT` groups the elements by a field of their root
277
+ * record. Wow 9.9 and later.
278
+ * @throws TypeError when `unit` is not an `AggregationDateUnit`,
279
+ * `timeZone` is blank, `dense` is not a boolean, or `field` or `alias` is
280
+ * invalid.
281
+ * @example
282
+ * ```typescript
283
+ * aggregation.dateHistogram('createTime', 'day', {
284
+ * unit: AggregationDateUnit.DAY,
285
+ * timeZone: 'Asia/Shanghai',
286
+ * });
287
+ * ```
288
+ */
289
+ dateHistogram<FIELDS extends string>(field: FIELDS, alias: string, { unit, timeZone, dense, scope }: DateHistogramAggregationOptions): DateHistogramAggregationGroup<FIELDS>;
290
+ /**
291
+ * Groups a time field by one calendar part of each instant, such as the
292
+ * weekday or the hour, so records from different days share a bucket.
293
+ * `{ type: 'date-part', field, part, alias, timeZone?, dense? }`.
294
+ *
295
+ * The group's keys in the result rows are integers: `DAY_OF_WEEK` is the
296
+ * ISO weekday, 1 (Monday) to 7 (Sunday); `DAY_OF_MONTH` 1 to 31;
297
+ * `HOUR_OF_DAY` 0 to 23 on the wall clock of `timeZone`; `MONTH_OF_YEAR`
298
+ * 1 to 12. With `dense`, every key of that domain comes back, those
299
+ * without records carrying each metric's empty value; `dense` needs the
300
+ * group to be the query's only one. Wow 9.2 and later.
301
+ *
302
+ * @param field - The time field (epoch milliseconds) to read the part of.
303
+ * @param alias - The name of the part column in the result rows.
304
+ * @param options.part - The calendar part to group by.
305
+ * @param options.timeZone - The zone the part is read in. Sent only when
306
+ * set; the server reads none as `UTC`.
307
+ * @param options.dense - Whether every key of the part's domain is
308
+ * returned.
309
+ * @param options.scope - What the field is relative to when the query
310
+ * expands elements: `ROOT` groups the elements by a field of their root
311
+ * record. Wow 9.9 and later.
312
+ * @throws TypeError when `part` is not an `AggregationDatePart`,
313
+ * `timeZone` is blank, `dense` is not a boolean, or `field` or `alias` is
314
+ * invalid.
315
+ * @example
316
+ * ```typescript
317
+ * aggregation.datePart('createTime', 'weekday', {
318
+ * part: AggregationDatePart.DAY_OF_WEEK,
319
+ * timeZone: 'Asia/Shanghai',
320
+ * });
321
+ * ```
322
+ */
323
+ datePart<FIELDS extends string>(field: FIELDS, alias: string, { part, timeZone, dense, scope }: DatePartAggregationOptions): DatePartAggregationGroup<FIELDS>;
324
+ };
325
+ export {};