@ahoo-wang/wow-client 10.0.0-alpha.7 → 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 +8 -5
- package/README.zh-CN.md +4 -3
- package/dist/commands.cjs +1 -1
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +9 -13
- package/dist/commands.d.ts +9 -13
- package/dist/commands.es.js +60 -54
- 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 +24 -379
- package/dist/dsl/descriptor.d.ts +24 -379
- package/dist/dsl/descriptor.es.js +6 -32
- 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 +5 -5
- package/dist/frameworkErrors.d.ts +5 -5
- 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 +30 -2
- package/dist/manifest.d.ts +30 -2
- package/dist/manifest.es.js +34 -6
- package/dist/manifest.es.js.map +1 -1
- package/dist/manifestTypes.d.cts +21 -4
- package/dist/manifestTypes.d.ts +21 -4
- 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 +18 -5
- package/dist/wait.d.ts +18 -5
- 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 +76 -31
- package/dist/wire.d.ts +76 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derived.cjs","names":["DerivedExpressionType","AggregationExpressionOperator","require_types","binary","derivedExpressionDsl","value","left","right","within","options"],"sources":["../../../src/dsl/aggregation/derived.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 { FieldSort, SortDirection } from '../sort.js';\nimport {\n AggregationExpressionOperator,\n DerivedExpressionType,\n type AggregationDateUnit,\n type DerivedExpression,\n type RunningFunction,\n} from './types.js';\n\n/**\n * The builders of a derived metric's arithmetic, handed to the callback of\n * `aggregation.derived(d => …, alias)`: references to other metrics of the\n * same row, numbers, and the four operators. Mirrors Kotlin's\n * `DerivedExpressionDsl` (`wow-query`, `AggregationQueryDsl.kt`).\n *\n * `constant` checks its number here; `aggregation.query()` checks what\n * spans the query: that each `ref` names a non-ANY metric declared before the\n * derived one, and the depth and size of the tree.\n *\n * These are not `aggregation.add` and friends: those build the expressions a\n * metric aggregates over, which name fields, not metrics.\n */\nexport interface DerivedExpressionDsl {\n /** The value of another metric of the row. `{ type: 'metric-ref', metric }`. */\n ref(metric: string): DerivedExpression;\n /**\n * A number. `{ type: 'constant', value }`.\n *\n * @throws TypeError when `value` is not finite.\n */\n constant(value: number): DerivedExpression;\n /** `left + right`. `{ type: 'binary', operator: 'add', left, right }`. */\n add(left: DerivedExpression, right: DerivedExpression): DerivedExpression;\n /** `left - right`. `{ type: 'binary', operator: 'subtract', left, right }`. */\n subtract(\n left: DerivedExpression,\n right: DerivedExpression,\n ): DerivedExpression;\n /** `left * right`. `{ type: 'binary', operator: 'multiply', left, right }`. */\n multiply(\n left: DerivedExpression,\n right: DerivedExpression,\n ): DerivedExpression;\n /** `left / right`. `{ type: 'binary', operator: 'divide', left, right }`. */\n divide(left: DerivedExpression, right: DerivedExpression): DerivedExpression;\n /**\n * `metric` summed over the groups sharing this group's `within` keys.\n * `{ type: 'total', metric, within }`.\n */\n total(metric: string, ...within: string[]): DerivedExpression;\n /**\n * `metric` accumulated along `order` within the groups sharing this group's\n * `within` keys; with `frame` and `function: 'avg'`, a moving average.\n */\n running(\n metric: string,\n order: FieldSort,\n options?: {\n within?: string[];\n frame?: number;\n function?: RunningFunction;\n },\n ): DerivedExpression;\n /**\n * `metric` of the group `shift` buckets (or `period`s) earlier along the\n * `DATE_HISTOGRAM` group `along`.\n */\n previous(\n metric: string,\n along: string,\n options?: { shift?: number; period?: AggregationDateUnit },\n ): DerivedExpression;\n /**\n * The dense rank of `metric` among the groups sharing this group's\n * `within` keys, `DESC` unless `direction` says otherwise.\n */\n rank(\n metric: string,\n options?: { within?: string[]; direction?: SortDirection },\n ): DerivedExpression;\n}\n\nfunction binary(\n operator: AggregationExpressionOperator,\n left: DerivedExpression,\n right: DerivedExpression,\n): DerivedExpression {\n return { type: DerivedExpressionType.BINARY, operator, left, right };\n}\n\nexport const derivedExpressionDsl: DerivedExpressionDsl = {\n ref: metric => ({ type: DerivedExpressionType.METRIC_REF, metric }),\n constant(value) {\n if (!Number.isFinite(value)) {\n throw new TypeError('derived constant must be finite.');\n }\n return { type: DerivedExpressionType.CONSTANT, value };\n },\n add: (left, right) => binary(AggregationExpressionOperator.ADD, left, right),\n subtract: (left, right) =>\n binary(AggregationExpressionOperator.SUBTRACT, left, right),\n multiply: (left, right) =>\n binary(AggregationExpressionOperator.MULTIPLY, left, right),\n divide: (left, right) =>\n binary(AggregationExpressionOperator.DIVIDE, left, right),\n total: (metric, ...within) => ({\n type: DerivedExpressionType.TOTAL,\n metric,\n ...(within.length > 0 && { within }),\n }),\n running: (metric, order, options = {}) => ({\n type: DerivedExpressionType.RUNNING,\n metric,\n order,\n ...options,\n }),\n previous: (metric, along, options = {}) => ({\n type: DerivedExpressionType.PREVIOUS,\n metric,\n along,\n ...options,\n }),\n rank: (metric, options = {}) => ({\n type: DerivedExpressionType.RANK,\n metric,\n ...options,\n }),\n};\n"],"mappings":"A,+BA+FA,SAASG,EACP,EACA,EACA,EACmB,CACnB,MAAO,CAAE,KAAMH,EAAAA,sBAAsB,OAAQ,WAAU,OAAM,OAAM,CACrE,CAEA,IAAaI,EAA6C,CACxD,IAAK,IAAW,CAAE,KAAMJ,EAAAA,sBAAsB,WAAY,QAAO,GACjE,SAAS,EAAO,CACd,GAAI,CAAC,OAAO,SAASK,CAAK,EACxB,MAAU,UAAU,kCAAkC,EAExD,MAAO,CAAE,KAAML,EAAAA,sBAAsB,SAAU,OAAM,CACvD,EACA,KAAM,EAAM,IAAUG,EAAOF,EAAAA,8BAA8B,IAAKK,EAAMC,CAAK,EAC3E,UAAW,EAAM,IACfJ,EAAOF,EAAAA,8BAA8B,SAAUK,EAAMC,CAAK,EAC5D,UAAW,EAAM,IACfJ,EAAOF,EAAAA,8BAA8B,SAAUK,EAAMC,CAAK,EAC5D,QAAS,EAAM,IACbJ,EAAOF,EAAAA,8BAA8B,OAAQK,EAAMC,CAAK,EAC1D,OAAQ,EAAQ,GAAGC,KAAY,CAC7B,KAAMR,EAAAA,sBAAsB,MAC5B,SACA,GAAIQ,EAAO,OAAS,GAAK,CAAE,QAAO,CACpC,GACA,SAAU,EAAQ,EAAO,EAAU,CAAC,KAAO,CACzC,KAAMR,EAAAA,sBAAsB,QAC5B,SACA,QACA,GAAGS,CACL,GACA,UAAW,EAAQ,EAAO,EAAU,CAAC,KAAO,CAC1C,KAAMT,EAAAA,sBAAsB,SAC5B,SACA,QACA,GAAGS,CACL,GACA,MAAO,EAAQ,EAAU,CAAC,KAAO,CAC/B,KAAMT,EAAAA,sBAAsB,KAC5B,SACA,GAAGS,CACL,EACF,E"}
|
|
1
|
+
{"version":3,"file":"derived.cjs","names":["AggregationExpressionOperator","AggregationMetricType","aggregationAlias","require_types","require_aliases","require_metrics","DerivedExpressionType","\"METRIC_REF\"","\"CONSTANT\"","\"BINARY\"","\"TOTAL\"","\"RUNNING\"","\"PREVIOUS\"","\"RANK\"","WindowFunction","RunningFunction","\"SUM\"","\"AVG\"","binary","derivedExpressionDsl","value","left","right","within","options","derivedBuilders","expression","alias"],"sources":["../../../src/dsl/aggregation/derived.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 { FieldSort, SortDirection } from '../sort.js';\nimport { AggregationMetricType } from './metrics.js';\nimport type { AggregationDateUnit } from './groups.js';\nimport { AggregationExpressionOperator } from './types.js';\nimport { aggregationAlias } from './aliases.js';\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 derivedBuilders.derived | `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/**\n * The builders of a derived metric's arithmetic, handed to the callback of\n * `aggregation.derived(d => …, alias)`: references to other metrics of the\n * same row, numbers, and the four operators. Mirrors Kotlin's\n * `DerivedExpressionDsl` (`wow-query`, `AggregationQueryDsl.kt`).\n *\n * `constant` checks its number here; `aggregation.query()` checks what\n * spans the query: that each `ref` names a non-ANY metric declared before the\n * derived one, and the depth and size of the tree.\n *\n * These are not `aggregation.add` and friends: those build the expressions a\n * metric aggregates over, which name fields, not metrics.\n */\nexport interface DerivedExpressionDsl {\n /** The value of another metric of the row. `{ type: 'metric-ref', metric }`. */\n ref(metric: string): DerivedExpression;\n /**\n * A number. `{ type: 'constant', value }`.\n *\n * @throws TypeError when `value` is not finite.\n */\n constant(value: number): DerivedExpression;\n /** `left + right`. `{ type: 'binary', operator: 'add', left, right }`. */\n add(left: DerivedExpression, right: DerivedExpression): DerivedExpression;\n /** `left - right`. `{ type: 'binary', operator: 'subtract', left, right }`. */\n subtract(\n left: DerivedExpression,\n right: DerivedExpression,\n ): DerivedExpression;\n /** `left * right`. `{ type: 'binary', operator: 'multiply', left, right }`. */\n multiply(\n left: DerivedExpression,\n right: DerivedExpression,\n ): DerivedExpression;\n /** `left / right`. `{ type: 'binary', operator: 'divide', left, right }`. */\n divide(left: DerivedExpression, right: DerivedExpression): DerivedExpression;\n /**\n * `metric` summed over the groups sharing this group's `within` keys.\n * `{ type: 'total', metric, within }`.\n */\n total(metric: string, ...within: string[]): DerivedExpression;\n /**\n * `metric` accumulated along `order` within the groups sharing this group's\n * `within` keys; with `frame` and `function: 'avg'`, a moving average.\n */\n running(\n metric: string,\n order: FieldSort,\n options?: {\n within?: string[];\n frame?: number;\n function?: RunningFunction;\n },\n ): DerivedExpression;\n /**\n * `metric` of the group `shift` buckets (or `period`s) earlier along the\n * `DATE_HISTOGRAM` group `along`.\n */\n previous(\n metric: string,\n along: string,\n options?: { shift?: number; period?: AggregationDateUnit },\n ): DerivedExpression;\n /**\n * The dense rank of `metric` among the groups sharing this group's\n * `within` keys, `DESC` unless `direction` says otherwise.\n */\n rank(\n metric: string,\n options?: { within?: string[]; direction?: SortDirection },\n ): DerivedExpression;\n}\n\nfunction binary(\n operator: AggregationExpressionOperator,\n left: DerivedExpression,\n right: DerivedExpression,\n): DerivedExpression {\n return { type: DerivedExpressionType.BINARY, operator, left, right };\n}\n\nexport const derivedExpressionDsl: DerivedExpressionDsl = {\n ref: metric => ({ type: DerivedExpressionType.METRIC_REF, metric }),\n constant(value) {\n if (!Number.isFinite(value)) {\n throw new TypeError('derived constant must be finite.');\n }\n return { type: DerivedExpressionType.CONSTANT, value };\n },\n add: (left, right) => binary(AggregationExpressionOperator.ADD, left, right),\n subtract: (left, right) =>\n binary(AggregationExpressionOperator.SUBTRACT, left, right),\n multiply: (left, right) =>\n binary(AggregationExpressionOperator.MULTIPLY, left, right),\n divide: (left, right) =>\n binary(AggregationExpressionOperator.DIVIDE, left, right),\n total: (metric, ...within) => ({\n type: DerivedExpressionType.TOTAL,\n metric,\n ...(within.length > 0 && { within }),\n }),\n running: (metric, order, options = {}) => ({\n type: DerivedExpressionType.RUNNING,\n metric,\n order,\n ...options,\n }),\n previous: (metric, along, options = {}) => ({\n type: DerivedExpressionType.PREVIOUS,\n metric,\n along,\n ...options,\n }),\n rank: (metric, options = {}) => ({\n type: DerivedExpressionType.RANK,\n metric,\n ...options,\n }),\n};\n\n/** The builder of a derived metric, computed from the metrics before it. */\nexport const derivedBuilders = {\n /**\n * A metric computed from other metrics of the same row, by their aliases.\n * `{ type: 'derived', expression, alias }`. `aggregation.query()` checks\n * that it refers only to metrics declared before it.\n *\n * @param expression - The arithmetic: a callback that builds it from the\n * {@link DerivedExpressionDsl} it is handed (`ref`, `constant`, `add`,\n * `subtract`, `multiply`, `divide`), or an already-built tree.\n * @throws TypeError when `alias` is invalid, or a `constant` is not finite.\n * @example\n * ```typescript\n * aggregation.derived(\n * d => d.divide(d.ref('revenue'), d.ref('orders')),\n * 'averageOrder',\n * );\n * ```\n */\n derived(\n expression:\n DerivedExpression | ((d: DerivedExpressionDsl) => DerivedExpression),\n alias: string,\n ): DerivedAggregationMetric {\n return {\n type: AggregationMetricType.DERIVED,\n expression:\n typeof expression === 'function'\n ? expression(derivedExpressionDsl)\n : expression,\n alias: aggregationAlias(alias),\n };\n },\n};\n"],"mappings":"A,qFAoBA,IAAYM,EAAL,SAAA,EAAA,C,MAEL,GAAAC,WAAA,aAEA,EAAAC,SAAA,WAEA,EAAAC,OAAA,SAEA,EAAAC,MAAA,QAEA,EAAAC,QAAA,UAEA,EAAAC,SAAA,WAEA,EAAAC,KAAA,O,CACF,EAAA,CAAA,CAAA,EAMYC,EAAL,SAAA,EAAA,C,MACL,GAAAJ,MAAA,QACA,EAAAC,QAAA,UACA,EAAAC,SAAA,WACA,EAAAC,KAAA,O,CACF,EAAA,CAAA,CAAA,EAGYE,EAAL,SAAA,EAAA,C,MACL,GAAAC,IAAA,MACA,EAAAC,IAAA,M,CACF,EAAA,CAAA,CAAA,EAmJA,SAASC,EACP,EACA,EACA,EACmB,CACnB,MAAO,CAAE,KAAA,SAAoC,WAAU,OAAM,OAAM,CACrE,CAEA,IAAaC,EAA6C,CACxD,IAAK,IAAW,CAAE,KAAA,aAAwC,QAAO,GACjE,SAAS,EAAO,CACd,GAAI,CAAC,OAAO,SAASC,CAAK,EACxB,MAAU,UAAU,kCAAkC,EAExD,MAAO,CAAE,KAAA,WAAsC,OAAM,CACvD,EACA,KAAM,EAAM,IAAUF,EAAOlB,EAAAA,8BAA8B,IAAKqB,EAAMC,CAAK,EAC3E,UAAW,EAAM,IACfJ,EAAOlB,EAAAA,8BAA8B,SAAUqB,EAAMC,CAAK,EAC5D,UAAW,EAAM,IACfJ,EAAOlB,EAAAA,8BAA8B,SAAUqB,EAAMC,CAAK,EAC5D,QAAS,EAAM,IACbJ,EAAOlB,EAAAA,8BAA8B,OAAQqB,EAAMC,CAAK,EAC1D,OAAQ,EAAQ,GAAGC,KAAY,CAC7B,KAAA,QACA,SACA,GAAIA,EAAO,OAAS,GAAK,CAAE,QAAO,CACpC,GACA,SAAU,EAAQ,EAAO,EAAU,CAAC,KAAO,CACzC,KAAA,UACA,SACA,QACA,GAAGC,CACL,GACA,UAAW,EAAQ,EAAO,EAAU,CAAC,KAAO,CAC1C,KAAA,WACA,SACA,QACA,GAAGA,CACL,GACA,MAAO,EAAQ,EAAU,CAAC,KAAO,CAC/B,KAAA,OACA,SACA,GAAGA,CACL,EACF,EAGaC,EAAkB,CAkB7B,QACE,EAEA,EAC0B,CAC1B,MAAO,CACL,KAAMxB,EAAAA,sBAAsB,QAC5B,WACE,OAAOyB,GAAe,WAClBA,EAAWP,CAAoB,EAC/BO,EACN,MAAOxB,EAAAA,iBAAiByB,CAAK,CAC/B,CACF,CACF,E"}
|
|
@@ -1,5 +1,106 @@
|
|
|
1
1
|
import { FieldSort, SortDirection } from '../sort.cjs';
|
|
2
|
-
import {
|
|
2
|
+
import { AggregationMetricType } from './metrics.cjs';
|
|
3
|
+
import { AggregationDateUnit } from './groups.cjs';
|
|
4
|
+
import { AggregationExpressionOperator } from './types.cjs';
|
|
5
|
+
/** The kind of a {@link DerivedExpression} node, sent as its `type`. */
|
|
6
|
+
export declare enum DerivedExpressionType {
|
|
7
|
+
/** The value of another metric of the row, by its alias. */
|
|
8
|
+
METRIC_REF = "metric-ref",
|
|
9
|
+
/** A number. */
|
|
10
|
+
CONSTANT = "constant",
|
|
11
|
+
/** Two operands and an {@link AggregationExpressionOperator}. */
|
|
12
|
+
BINARY = "binary",
|
|
13
|
+
/** A window: the metric summed over a partition of the groups. */
|
|
14
|
+
TOTAL = "total",
|
|
15
|
+
/** A window: the metric accumulated along an order, or its moving average. */
|
|
16
|
+
RUNNING = "running",
|
|
17
|
+
/** A window: the metric of an earlier period along a date group. */
|
|
18
|
+
PREVIOUS = "previous",
|
|
19
|
+
/** A window: the dense rank of the metric within a partition. */
|
|
20
|
+
RANK = "rank"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The window functions of derived expressions, as a storage declares them in
|
|
24
|
+
* `analysis.windows` of its descriptor.
|
|
25
|
+
*/
|
|
26
|
+
export declare enum WindowFunction {
|
|
27
|
+
TOTAL = "total",
|
|
28
|
+
RUNNING = "running",
|
|
29
|
+
PREVIOUS = "previous",
|
|
30
|
+
RANK = "rank"
|
|
31
|
+
}
|
|
32
|
+
/** What a `RUNNING` window computes over its frame. */
|
|
33
|
+
export declare enum RunningFunction {
|
|
34
|
+
SUM = "sum",
|
|
35
|
+
AVG = "avg"
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A window over the groups of the aggregation. Wow computes it over every
|
|
39
|
+
* group the filter selects, before `having`, `sort` and `limit`; `metric`
|
|
40
|
+
* names a non-derived numeric metric declared before the derived one, and
|
|
41
|
+
* `within`, `order` and `along` name groups of the query. Wow 9.9 and later,
|
|
42
|
+
* where `analysis.windows` lists the function.
|
|
43
|
+
*/
|
|
44
|
+
export type DerivedWindow = {
|
|
45
|
+
type: DerivedExpressionType.TOTAL;
|
|
46
|
+
/** A `COUNT` or `SUM` metric. */
|
|
47
|
+
metric: string;
|
|
48
|
+
/** The partition's group aliases; every group when absent. */
|
|
49
|
+
within?: string[];
|
|
50
|
+
} | {
|
|
51
|
+
type: DerivedExpressionType.RUNNING;
|
|
52
|
+
/** A `COUNT` or `SUM` metric for `SUM`; any numeric metric for `AVG`. */
|
|
53
|
+
metric: string;
|
|
54
|
+
/** A group alias or a non-derived numeric metric, with its direction. */
|
|
55
|
+
order: FieldSort;
|
|
56
|
+
within?: string[];
|
|
57
|
+
/** The last this many groups; every group up to this one when absent. */
|
|
58
|
+
frame?: number;
|
|
59
|
+
/** `SUM` when absent. */
|
|
60
|
+
function?: RunningFunction;
|
|
61
|
+
} | {
|
|
62
|
+
type: DerivedExpressionType.PREVIOUS;
|
|
63
|
+
metric: string;
|
|
64
|
+
/** The alias of a `DATE_HISTOGRAM` group. */
|
|
65
|
+
along: string;
|
|
66
|
+
/** How many steps back; 1 when absent. */
|
|
67
|
+
shift?: number;
|
|
68
|
+
/** Step by this calendar period instead of by one bucket of `along`. */
|
|
69
|
+
period?: AggregationDateUnit;
|
|
70
|
+
} | {
|
|
71
|
+
type: DerivedExpressionType.RANK;
|
|
72
|
+
metric: string;
|
|
73
|
+
within?: string[];
|
|
74
|
+
/** `DESC` when absent. */
|
|
75
|
+
direction?: SortDirection;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Post-aggregation arithmetic; references must name earlier metrics that are
|
|
79
|
+
* not `ANY`, `FIRST` or `LAST`.
|
|
80
|
+
*/
|
|
81
|
+
export type DerivedExpression = {
|
|
82
|
+
type: DerivedExpressionType.METRIC_REF;
|
|
83
|
+
metric: string;
|
|
84
|
+
} | {
|
|
85
|
+
type: DerivedExpressionType.CONSTANT;
|
|
86
|
+
value: number;
|
|
87
|
+
} | {
|
|
88
|
+
type: DerivedExpressionType.BINARY;
|
|
89
|
+
operator: AggregationExpressionOperator;
|
|
90
|
+
left: DerivedExpression;
|
|
91
|
+
right: DerivedExpression;
|
|
92
|
+
} | DerivedWindow;
|
|
93
|
+
/**
|
|
94
|
+
* A metric computed from metrics declared before it in the same query, after
|
|
95
|
+
* aggregation; {@link derivedBuilders.derived | `aggregation.derived`}. Wow 9.1 and later.
|
|
96
|
+
*/
|
|
97
|
+
export interface DerivedAggregationMetric {
|
|
98
|
+
type: AggregationMetricType.DERIVED;
|
|
99
|
+
/** The arithmetic over the other metrics. */
|
|
100
|
+
expression: DerivedExpression;
|
|
101
|
+
/** The name of the metric's column in the result rows. */
|
|
102
|
+
alias: string;
|
|
103
|
+
}
|
|
3
104
|
/**
|
|
4
105
|
* The builders of a derived metric's arithmetic, handed to the callback of
|
|
5
106
|
* `aggregation.derived(d => …, alias)`: references to other metrics of the
|
|
@@ -62,3 +163,24 @@ export interface DerivedExpressionDsl {
|
|
|
62
163
|
}): DerivedExpression;
|
|
63
164
|
}
|
|
64
165
|
export declare const derivedExpressionDsl: DerivedExpressionDsl;
|
|
166
|
+
/** The builder of a derived metric, computed from the metrics before it. */
|
|
167
|
+
export declare const derivedBuilders: {
|
|
168
|
+
/**
|
|
169
|
+
* A metric computed from other metrics of the same row, by their aliases.
|
|
170
|
+
* `{ type: 'derived', expression, alias }`. `aggregation.query()` checks
|
|
171
|
+
* that it refers only to metrics declared before it.
|
|
172
|
+
*
|
|
173
|
+
* @param expression - The arithmetic: a callback that builds it from the
|
|
174
|
+
* {@link DerivedExpressionDsl} it is handed (`ref`, `constant`, `add`,
|
|
175
|
+
* `subtract`, `multiply`, `divide`), or an already-built tree.
|
|
176
|
+
* @throws TypeError when `alias` is invalid, or a `constant` is not finite.
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* aggregation.derived(
|
|
180
|
+
* d => d.divide(d.ref('revenue'), d.ref('orders')),
|
|
181
|
+
* 'averageOrder',
|
|
182
|
+
* );
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
derived(expression: DerivedExpression | ((d: DerivedExpressionDsl) => DerivedExpression), alias: string): DerivedAggregationMetric;
|
|
186
|
+
};
|
|
@@ -1,5 +1,106 @@
|
|
|
1
1
|
import { FieldSort, SortDirection } from '../sort.js';
|
|
2
|
-
import {
|
|
2
|
+
import { AggregationMetricType } from './metrics.js';
|
|
3
|
+
import { AggregationDateUnit } from './groups.js';
|
|
4
|
+
import { AggregationExpressionOperator } from './types.js';
|
|
5
|
+
/** The kind of a {@link DerivedExpression} node, sent as its `type`. */
|
|
6
|
+
export declare enum DerivedExpressionType {
|
|
7
|
+
/** The value of another metric of the row, by its alias. */
|
|
8
|
+
METRIC_REF = "metric-ref",
|
|
9
|
+
/** A number. */
|
|
10
|
+
CONSTANT = "constant",
|
|
11
|
+
/** Two operands and an {@link AggregationExpressionOperator}. */
|
|
12
|
+
BINARY = "binary",
|
|
13
|
+
/** A window: the metric summed over a partition of the groups. */
|
|
14
|
+
TOTAL = "total",
|
|
15
|
+
/** A window: the metric accumulated along an order, or its moving average. */
|
|
16
|
+
RUNNING = "running",
|
|
17
|
+
/** A window: the metric of an earlier period along a date group. */
|
|
18
|
+
PREVIOUS = "previous",
|
|
19
|
+
/** A window: the dense rank of the metric within a partition. */
|
|
20
|
+
RANK = "rank"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The window functions of derived expressions, as a storage declares them in
|
|
24
|
+
* `analysis.windows` of its descriptor.
|
|
25
|
+
*/
|
|
26
|
+
export declare enum WindowFunction {
|
|
27
|
+
TOTAL = "total",
|
|
28
|
+
RUNNING = "running",
|
|
29
|
+
PREVIOUS = "previous",
|
|
30
|
+
RANK = "rank"
|
|
31
|
+
}
|
|
32
|
+
/** What a `RUNNING` window computes over its frame. */
|
|
33
|
+
export declare enum RunningFunction {
|
|
34
|
+
SUM = "sum",
|
|
35
|
+
AVG = "avg"
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A window over the groups of the aggregation. Wow computes it over every
|
|
39
|
+
* group the filter selects, before `having`, `sort` and `limit`; `metric`
|
|
40
|
+
* names a non-derived numeric metric declared before the derived one, and
|
|
41
|
+
* `within`, `order` and `along` name groups of the query. Wow 9.9 and later,
|
|
42
|
+
* where `analysis.windows` lists the function.
|
|
43
|
+
*/
|
|
44
|
+
export type DerivedWindow = {
|
|
45
|
+
type: DerivedExpressionType.TOTAL;
|
|
46
|
+
/** A `COUNT` or `SUM` metric. */
|
|
47
|
+
metric: string;
|
|
48
|
+
/** The partition's group aliases; every group when absent. */
|
|
49
|
+
within?: string[];
|
|
50
|
+
} | {
|
|
51
|
+
type: DerivedExpressionType.RUNNING;
|
|
52
|
+
/** A `COUNT` or `SUM` metric for `SUM`; any numeric metric for `AVG`. */
|
|
53
|
+
metric: string;
|
|
54
|
+
/** A group alias or a non-derived numeric metric, with its direction. */
|
|
55
|
+
order: FieldSort;
|
|
56
|
+
within?: string[];
|
|
57
|
+
/** The last this many groups; every group up to this one when absent. */
|
|
58
|
+
frame?: number;
|
|
59
|
+
/** `SUM` when absent. */
|
|
60
|
+
function?: RunningFunction;
|
|
61
|
+
} | {
|
|
62
|
+
type: DerivedExpressionType.PREVIOUS;
|
|
63
|
+
metric: string;
|
|
64
|
+
/** The alias of a `DATE_HISTOGRAM` group. */
|
|
65
|
+
along: string;
|
|
66
|
+
/** How many steps back; 1 when absent. */
|
|
67
|
+
shift?: number;
|
|
68
|
+
/** Step by this calendar period instead of by one bucket of `along`. */
|
|
69
|
+
period?: AggregationDateUnit;
|
|
70
|
+
} | {
|
|
71
|
+
type: DerivedExpressionType.RANK;
|
|
72
|
+
metric: string;
|
|
73
|
+
within?: string[];
|
|
74
|
+
/** `DESC` when absent. */
|
|
75
|
+
direction?: SortDirection;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Post-aggregation arithmetic; references must name earlier metrics that are
|
|
79
|
+
* not `ANY`, `FIRST` or `LAST`.
|
|
80
|
+
*/
|
|
81
|
+
export type DerivedExpression = {
|
|
82
|
+
type: DerivedExpressionType.METRIC_REF;
|
|
83
|
+
metric: string;
|
|
84
|
+
} | {
|
|
85
|
+
type: DerivedExpressionType.CONSTANT;
|
|
86
|
+
value: number;
|
|
87
|
+
} | {
|
|
88
|
+
type: DerivedExpressionType.BINARY;
|
|
89
|
+
operator: AggregationExpressionOperator;
|
|
90
|
+
left: DerivedExpression;
|
|
91
|
+
right: DerivedExpression;
|
|
92
|
+
} | DerivedWindow;
|
|
93
|
+
/**
|
|
94
|
+
* A metric computed from metrics declared before it in the same query, after
|
|
95
|
+
* aggregation; {@link derivedBuilders.derived | `aggregation.derived`}. Wow 9.1 and later.
|
|
96
|
+
*/
|
|
97
|
+
export interface DerivedAggregationMetric {
|
|
98
|
+
type: AggregationMetricType.DERIVED;
|
|
99
|
+
/** The arithmetic over the other metrics. */
|
|
100
|
+
expression: DerivedExpression;
|
|
101
|
+
/** The name of the metric's column in the result rows. */
|
|
102
|
+
alias: string;
|
|
103
|
+
}
|
|
3
104
|
/**
|
|
4
105
|
* The builders of a derived metric's arithmetic, handed to the callback of
|
|
5
106
|
* `aggregation.derived(d => …, alias)`: references to other metrics of the
|
|
@@ -62,3 +163,24 @@ export interface DerivedExpressionDsl {
|
|
|
62
163
|
}): DerivedExpression;
|
|
63
164
|
}
|
|
64
165
|
export declare const derivedExpressionDsl: DerivedExpressionDsl;
|
|
166
|
+
/** The builder of a derived metric, computed from the metrics before it. */
|
|
167
|
+
export declare const derivedBuilders: {
|
|
168
|
+
/**
|
|
169
|
+
* A metric computed from other metrics of the same row, by their aliases.
|
|
170
|
+
* `{ type: 'derived', expression, alias }`. `aggregation.query()` checks
|
|
171
|
+
* that it refers only to metrics declared before it.
|
|
172
|
+
*
|
|
173
|
+
* @param expression - The arithmetic: a callback that builds it from the
|
|
174
|
+
* {@link DerivedExpressionDsl} it is handed (`ref`, `constant`, `add`,
|
|
175
|
+
* `subtract`, `multiply`, `divide`), or an already-built tree.
|
|
176
|
+
* @throws TypeError when `alias` is invalid, or a `constant` is not finite.
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* aggregation.derived(
|
|
180
|
+
* d => d.divide(d.ref('revenue'), d.ref('orders')),
|
|
181
|
+
* 'averageOrder',
|
|
182
|
+
* );
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
derived(expression: DerivedExpression | ((d: DerivedExpressionDsl) => DerivedExpression), alias: string): DerivedAggregationMetric;
|
|
186
|
+
};
|
|
@@ -1,52 +1,67 @@
|
|
|
1
|
-
import { AggregationExpressionOperator as e
|
|
1
|
+
import { AggregationExpressionOperator as e } from "./types.es.js";
|
|
2
|
+
import { aggregationAlias as t } from "./aliases.es.js";
|
|
3
|
+
import { AggregationMetricType as n } from "./metrics.es.js";
|
|
2
4
|
// src/dsl/aggregation/derived.ts
|
|
3
|
-
function
|
|
5
|
+
var r = /* @__PURE__ */ function(e) {
|
|
6
|
+
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;
|
|
7
|
+
}({}), i = /* @__PURE__ */ function(e) {
|
|
8
|
+
return e.TOTAL = "total", e.RUNNING = "running", e.PREVIOUS = "previous", e.RANK = "rank", e;
|
|
9
|
+
}({}), a = /* @__PURE__ */ function(e) {
|
|
10
|
+
return e.SUM = "sum", e.AVG = "avg", e;
|
|
11
|
+
}({});
|
|
12
|
+
function o(e, t, n) {
|
|
4
13
|
return {
|
|
5
|
-
type:
|
|
14
|
+
type: "binary",
|
|
6
15
|
operator: e,
|
|
7
|
-
left:
|
|
8
|
-
right:
|
|
16
|
+
left: t,
|
|
17
|
+
right: n
|
|
9
18
|
};
|
|
10
19
|
}
|
|
11
|
-
var
|
|
20
|
+
var s = {
|
|
12
21
|
ref: (e) => ({
|
|
13
|
-
type:
|
|
22
|
+
type: "metric-ref",
|
|
14
23
|
metric: e
|
|
15
24
|
}),
|
|
16
25
|
constant(e) {
|
|
17
26
|
if (!Number.isFinite(e)) throw TypeError("derived constant must be finite.");
|
|
18
27
|
return {
|
|
19
|
-
type:
|
|
28
|
+
type: "constant",
|
|
20
29
|
value: e
|
|
21
30
|
};
|
|
22
31
|
},
|
|
23
|
-
add: (t,
|
|
24
|
-
subtract: (t,
|
|
25
|
-
multiply: (t,
|
|
26
|
-
divide: (t,
|
|
27
|
-
total: (e, ...
|
|
28
|
-
type:
|
|
32
|
+
add: (t, n) => o(e.ADD, t, n),
|
|
33
|
+
subtract: (t, n) => o(e.SUBTRACT, t, n),
|
|
34
|
+
multiply: (t, n) => o(e.MULTIPLY, t, n),
|
|
35
|
+
divide: (t, n) => o(e.DIVIDE, t, n),
|
|
36
|
+
total: (e, ...t) => ({
|
|
37
|
+
type: "total",
|
|
29
38
|
metric: e,
|
|
30
|
-
...
|
|
39
|
+
...t.length > 0 && { within: t }
|
|
31
40
|
}),
|
|
32
|
-
running: (e,
|
|
33
|
-
type:
|
|
41
|
+
running: (e, t, n = {}) => ({
|
|
42
|
+
type: "running",
|
|
34
43
|
metric: e,
|
|
35
|
-
order:
|
|
36
|
-
...
|
|
44
|
+
order: t,
|
|
45
|
+
...n
|
|
37
46
|
}),
|
|
38
|
-
previous: (e,
|
|
39
|
-
type:
|
|
47
|
+
previous: (e, t, n = {}) => ({
|
|
48
|
+
type: "previous",
|
|
40
49
|
metric: e,
|
|
41
|
-
along:
|
|
42
|
-
...
|
|
50
|
+
along: t,
|
|
51
|
+
...n
|
|
43
52
|
}),
|
|
44
|
-
rank: (e,
|
|
45
|
-
type:
|
|
53
|
+
rank: (e, t = {}) => ({
|
|
54
|
+
type: "rank",
|
|
46
55
|
metric: e,
|
|
47
|
-
...
|
|
56
|
+
...t
|
|
48
57
|
})
|
|
49
|
-
}
|
|
50
|
-
|
|
58
|
+
}, c = { derived(e, r) {
|
|
59
|
+
return {
|
|
60
|
+
type: n.DERIVED,
|
|
61
|
+
expression: typeof e == "function" ? e(s) : e,
|
|
62
|
+
alias: t(r)
|
|
63
|
+
};
|
|
64
|
+
} };
|
|
65
|
+
export { r as DerivedExpressionType, a as RunningFunction, i as WindowFunction, c as derivedBuilders, s as derivedExpressionDsl };
|
|
51
66
|
|
|
52
67
|
//# sourceMappingURL=derived.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derived.es.js","names":["binary","DerivedExpressionType","derivedExpressionDsl","value","AggregationExpressionOperator","left","right","within","options"],"sources":["../../../src/dsl/aggregation/derived.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 { FieldSort, SortDirection } from '../sort.js';\nimport {\n AggregationExpressionOperator,\n DerivedExpressionType,\n type AggregationDateUnit,\n type DerivedExpression,\n type RunningFunction,\n} from './types.js';\n\n/**\n * The builders of a derived metric's arithmetic, handed to the callback of\n * `aggregation.derived(d => …, alias)`: references to other metrics of the\n * same row, numbers, and the four operators. Mirrors Kotlin's\n * `DerivedExpressionDsl` (`wow-query`, `AggregationQueryDsl.kt`).\n *\n * `constant` checks its number here; `aggregation.query()` checks what\n * spans the query: that each `ref` names a non-ANY metric declared before the\n * derived one, and the depth and size of the tree.\n *\n * These are not `aggregation.add` and friends: those build the expressions a\n * metric aggregates over, which name fields, not metrics.\n */\nexport interface DerivedExpressionDsl {\n /** The value of another metric of the row. `{ type: 'metric-ref', metric }`. */\n ref(metric: string): DerivedExpression;\n /**\n * A number. `{ type: 'constant', value }`.\n *\n * @throws TypeError when `value` is not finite.\n */\n constant(value: number): DerivedExpression;\n /** `left + right`. `{ type: 'binary', operator: 'add', left, right }`. */\n add(left: DerivedExpression, right: DerivedExpression): DerivedExpression;\n /** `left - right`. `{ type: 'binary', operator: 'subtract', left, right }`. */\n subtract(\n left: DerivedExpression,\n right: DerivedExpression,\n ): DerivedExpression;\n /** `left * right`. `{ type: 'binary', operator: 'multiply', left, right }`. */\n multiply(\n left: DerivedExpression,\n right: DerivedExpression,\n ): DerivedExpression;\n /** `left / right`. `{ type: 'binary', operator: 'divide', left, right }`. */\n divide(left: DerivedExpression, right: DerivedExpression): DerivedExpression;\n /**\n * `metric` summed over the groups sharing this group's `within` keys.\n * `{ type: 'total', metric, within }`.\n */\n total(metric: string, ...within: string[]): DerivedExpression;\n /**\n * `metric` accumulated along `order` within the groups sharing this group's\n * `within` keys; with `frame` and `function: 'avg'`, a moving average.\n */\n running(\n metric: string,\n order: FieldSort,\n options?: {\n within?: string[];\n frame?: number;\n function?: RunningFunction;\n },\n ): DerivedExpression;\n /**\n * `metric` of the group `shift` buckets (or `period`s) earlier along the\n * `DATE_HISTOGRAM` group `along`.\n */\n previous(\n metric: string,\n along: string,\n options?: { shift?: number; period?: AggregationDateUnit },\n ): DerivedExpression;\n /**\n * The dense rank of `metric` among the groups sharing this group's\n * `within` keys, `DESC` unless `direction` says otherwise.\n */\n rank(\n metric: string,\n options?: { within?: string[]; direction?: SortDirection },\n ): DerivedExpression;\n}\n\nfunction binary(\n operator: AggregationExpressionOperator,\n left: DerivedExpression,\n right: DerivedExpression,\n): DerivedExpression {\n return { type: DerivedExpressionType.BINARY, operator, left, right };\n}\n\nexport const derivedExpressionDsl: DerivedExpressionDsl = {\n ref: metric => ({ type: DerivedExpressionType.METRIC_REF, metric }),\n constant(value) {\n if (!Number.isFinite(value)) {\n throw new TypeError('derived constant must be finite.');\n }\n return { type: DerivedExpressionType.CONSTANT, value };\n },\n add: (left, right) => binary(AggregationExpressionOperator.ADD, left, right),\n subtract: (left, right) =>\n binary(AggregationExpressionOperator.SUBTRACT, left, right),\n multiply: (left, right) =>\n binary(AggregationExpressionOperator.MULTIPLY, left, right),\n divide: (left, right) =>\n binary(AggregationExpressionOperator.DIVIDE, left, right),\n total: (metric, ...within) => ({\n type: DerivedExpressionType.TOTAL,\n metric,\n ...(within.length > 0 && { within }),\n }),\n running: (metric, order, options = {}) => ({\n type: DerivedExpressionType.RUNNING,\n metric,\n order,\n ...options,\n }),\n previous: (metric, along, options = {}) => ({\n type: DerivedExpressionType.PREVIOUS,\n metric,\n along,\n ...options,\n }),\n rank: (metric, options = {}) => ({\n type: DerivedExpressionType.RANK,\n metric,\n ...options,\n }),\n};\n"],"mappings":";;AA+FA,SAASA,EACP,GACA,GACA,GACmB;CACnB,OAAO;EAAE,MAAMC,EAAsB;EAAQ;EAAU;EAAM;CAAM;AACrE;AAEA,IAAaC,IAA6C;CACxD,MAAK,OAAW;EAAE,MAAMD,EAAsB;EAAY;CAAO;CACjE,SAAS,GAAO;EACd,IAAI,CAAC,OAAO,SAASE,CAAK,GACxB,MAAU,UAAU,kCAAkC;EAExD,OAAO;GAAE,MAAMF,EAAsB;GAAU;EAAM;CACvD;CACA,MAAM,GAAM,MAAUD,EAAOI,EAA8B,KAAKC,GAAMC,CAAK;CAC3E,WAAW,GAAM,MACfN,EAAOI,EAA8B,UAAUC,GAAMC,CAAK;CAC5D,WAAW,GAAM,MACfN,EAAOI,EAA8B,UAAUC,GAAMC,CAAK;CAC5D,SAAS,GAAM,MACbN,EAAOI,EAA8B,QAAQC,GAAMC,CAAK;CAC1D,QAAQ,GAAQ,GAAGC,OAAY;EAC7B,MAAMN,EAAsB;EAC5B;EACA,GAAIM,EAAO,SAAS,KAAK,EAAE,UAAO;CACpC;CACA,UAAU,GAAQ,GAAO,IAAU,CAAC,OAAO;EACzC,MAAMN,EAAsB;EAC5B;EACA;EACA,GAAGO;CACL;CACA,WAAW,GAAQ,GAAO,IAAU,CAAC,OAAO;EAC1C,MAAMP,EAAsB;EAC5B;EACA;EACA,GAAGO;CACL;CACA,OAAO,GAAQ,IAAU,CAAC,OAAO;EAC/B,MAAMP,EAAsB;EAC5B;EACA,GAAGO;CACL;AACF"}
|
|
1
|
+
{"version":3,"file":"derived.es.js","names":["DerivedExpressionType","\"METRIC_REF\"","\"CONSTANT\"","\"BINARY\"","\"TOTAL\"","\"RUNNING\"","\"PREVIOUS\"","\"RANK\"","WindowFunction","RunningFunction","\"SUM\"","\"AVG\"","binary","derivedExpressionDsl","value","AggregationExpressionOperator","left","right","within","options","derivedBuilders","AggregationMetricType","expression","aggregationAlias","alias"],"sources":["../../../src/dsl/aggregation/derived.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 { FieldSort, SortDirection } from '../sort.js';\nimport { AggregationMetricType } from './metrics.js';\nimport type { AggregationDateUnit } from './groups.js';\nimport { AggregationExpressionOperator } from './types.js';\nimport { aggregationAlias } from './aliases.js';\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 derivedBuilders.derived | `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/**\n * The builders of a derived metric's arithmetic, handed to the callback of\n * `aggregation.derived(d => …, alias)`: references to other metrics of the\n * same row, numbers, and the four operators. Mirrors Kotlin's\n * `DerivedExpressionDsl` (`wow-query`, `AggregationQueryDsl.kt`).\n *\n * `constant` checks its number here; `aggregation.query()` checks what\n * spans the query: that each `ref` names a non-ANY metric declared before the\n * derived one, and the depth and size of the tree.\n *\n * These are not `aggregation.add` and friends: those build the expressions a\n * metric aggregates over, which name fields, not metrics.\n */\nexport interface DerivedExpressionDsl {\n /** The value of another metric of the row. `{ type: 'metric-ref', metric }`. */\n ref(metric: string): DerivedExpression;\n /**\n * A number. `{ type: 'constant', value }`.\n *\n * @throws TypeError when `value` is not finite.\n */\n constant(value: number): DerivedExpression;\n /** `left + right`. `{ type: 'binary', operator: 'add', left, right }`. */\n add(left: DerivedExpression, right: DerivedExpression): DerivedExpression;\n /** `left - right`. `{ type: 'binary', operator: 'subtract', left, right }`. */\n subtract(\n left: DerivedExpression,\n right: DerivedExpression,\n ): DerivedExpression;\n /** `left * right`. `{ type: 'binary', operator: 'multiply', left, right }`. */\n multiply(\n left: DerivedExpression,\n right: DerivedExpression,\n ): DerivedExpression;\n /** `left / right`. `{ type: 'binary', operator: 'divide', left, right }`. */\n divide(left: DerivedExpression, right: DerivedExpression): DerivedExpression;\n /**\n * `metric` summed over the groups sharing this group's `within` keys.\n * `{ type: 'total', metric, within }`.\n */\n total(metric: string, ...within: string[]): DerivedExpression;\n /**\n * `metric` accumulated along `order` within the groups sharing this group's\n * `within` keys; with `frame` and `function: 'avg'`, a moving average.\n */\n running(\n metric: string,\n order: FieldSort,\n options?: {\n within?: string[];\n frame?: number;\n function?: RunningFunction;\n },\n ): DerivedExpression;\n /**\n * `metric` of the group `shift` buckets (or `period`s) earlier along the\n * `DATE_HISTOGRAM` group `along`.\n */\n previous(\n metric: string,\n along: string,\n options?: { shift?: number; period?: AggregationDateUnit },\n ): DerivedExpression;\n /**\n * The dense rank of `metric` among the groups sharing this group's\n * `within` keys, `DESC` unless `direction` says otherwise.\n */\n rank(\n metric: string,\n options?: { within?: string[]; direction?: SortDirection },\n ): DerivedExpression;\n}\n\nfunction binary(\n operator: AggregationExpressionOperator,\n left: DerivedExpression,\n right: DerivedExpression,\n): DerivedExpression {\n return { type: DerivedExpressionType.BINARY, operator, left, right };\n}\n\nexport const derivedExpressionDsl: DerivedExpressionDsl = {\n ref: metric => ({ type: DerivedExpressionType.METRIC_REF, metric }),\n constant(value) {\n if (!Number.isFinite(value)) {\n throw new TypeError('derived constant must be finite.');\n }\n return { type: DerivedExpressionType.CONSTANT, value };\n },\n add: (left, right) => binary(AggregationExpressionOperator.ADD, left, right),\n subtract: (left, right) =>\n binary(AggregationExpressionOperator.SUBTRACT, left, right),\n multiply: (left, right) =>\n binary(AggregationExpressionOperator.MULTIPLY, left, right),\n divide: (left, right) =>\n binary(AggregationExpressionOperator.DIVIDE, left, right),\n total: (metric, ...within) => ({\n type: DerivedExpressionType.TOTAL,\n metric,\n ...(within.length > 0 && { within }),\n }),\n running: (metric, order, options = {}) => ({\n type: DerivedExpressionType.RUNNING,\n metric,\n order,\n ...options,\n }),\n previous: (metric, along, options = {}) => ({\n type: DerivedExpressionType.PREVIOUS,\n metric,\n along,\n ...options,\n }),\n rank: (metric, options = {}) => ({\n type: DerivedExpressionType.RANK,\n metric,\n ...options,\n }),\n};\n\n/** The builder of a derived metric, computed from the metrics before it. */\nexport const derivedBuilders = {\n /**\n * A metric computed from other metrics of the same row, by their aliases.\n * `{ type: 'derived', expression, alias }`. `aggregation.query()` checks\n * that it refers only to metrics declared before it.\n *\n * @param expression - The arithmetic: a callback that builds it from the\n * {@link DerivedExpressionDsl} it is handed (`ref`, `constant`, `add`,\n * `subtract`, `multiply`, `divide`), or an already-built tree.\n * @throws TypeError when `alias` is invalid, or a `constant` is not finite.\n * @example\n * ```typescript\n * aggregation.derived(\n * d => d.divide(d.ref('revenue'), d.ref('orders')),\n * 'averageOrder',\n * );\n * ```\n */\n derived(\n expression:\n DerivedExpression | ((d: DerivedExpressionDsl) => DerivedExpression),\n alias: string,\n ): DerivedAggregationMetric {\n return {\n type: AggregationMetricType.DERIVED,\n expression:\n typeof expression === 'function'\n ? expression(derivedExpressionDsl)\n : expression,\n alias: aggregationAlias(alias),\n };\n },\n};\n"],"mappings":";;;;AAoBA,IAAYA,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,aAAA,cAEA,EAAAC,WAAA,YAEA,EAAAC,SAAA,UAEA,EAAAC,QAAA,SAEA,EAAAC,UAAA,WAEA,EAAAC,WAAA,YAEA,EAAAC,OAAA,Q;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;C,OACL,EAAAJ,QAAA,SACA,EAAAC,UAAA,WACA,EAAAC,WAAA,YACA,EAAAC,OAAA,Q;AACF,EAAA,CAAA,CAAA,GAGYE,IAAL,yBAAA,GAAA;C,OACL,EAAAC,MAAA,OACA,EAAAC,MAAA,O;AACF,EAAA,CAAA,CAAA;AAmJA,SAASC,EACP,GACA,GACA,GACmB;CACnB,OAAO;EAAE,MAAA;EAAoC;EAAU;EAAM;CAAM;AACrE;AAEA,IAAaC,IAA6C;CACxD,MAAK,OAAW;EAAE,MAAA;EAAwC;CAAO;CACjE,SAAS,GAAO;EACd,IAAI,CAAC,OAAO,SAASC,CAAK,GACxB,MAAU,UAAU,kCAAkC;EAExD,OAAO;GAAE,MAAA;GAAsC;EAAM;CACvD;CACA,MAAM,GAAM,MAAUF,EAAOG,EAA8B,KAAKC,GAAMC,CAAK;CAC3E,WAAW,GAAM,MACfL,EAAOG,EAA8B,UAAUC,GAAMC,CAAK;CAC5D,WAAW,GAAM,MACfL,EAAOG,EAA8B,UAAUC,GAAMC,CAAK;CAC5D,SAAS,GAAM,MACbL,EAAOG,EAA8B,QAAQC,GAAMC,CAAK;CAC1D,QAAQ,GAAQ,GAAGC,OAAY;EAC7B,MAAA;EACA;EACA,GAAIA,EAAO,SAAS,KAAK,EAAE,UAAO;CACpC;CACA,UAAU,GAAQ,GAAO,IAAU,CAAC,OAAO;EACzC,MAAA;EACA;EACA;EACA,GAAGC;CACL;CACA,WAAW,GAAQ,GAAO,IAAU,CAAC,OAAO;EAC1C,MAAA;EACA;EACA;EACA,GAAGA;CACL;CACA,OAAO,GAAQ,IAAU,CAAC,OAAO;EAC/B,MAAA;EACA;EACA,GAAGA;CACL;AACF,GAGaC,IAAkB,EAkB7B,QACE,GAEA,GAC0B;CAC1B,OAAO;EACL,MAAMC,EAAsB;EAC5B,YACE,OAAOC,KAAe,aAClBA,EAAWT,CAAoB,IAC/BS;EACN,OAAOC,EAAiBC,CAAK;CAC/B;AACF,EACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./expressionTrees.cjs"),t=require("../constantName.cjs"),n=require("./aliases.cjs");var r=function(e){return e.TERMS=`terms`,e.HISTOGRAM=`histogram`,e.DATE_HISTOGRAM=`date-histogram`,e.DATE_PART=`date-part`,e}({}),i=function(e){return e.ELEMENT=`element`,e.ROOT=`root`,e}({}),a=function(e){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}({}),o=function(e){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}({});function s(r,i){if(typeof r==`string`)return{field:n.aggregationField(r)};if(typeof r!=`object`||!r)throw TypeError(`${t.constantName(i)} group requires exactly one of field and expression.`);return e.requireValidExpressionTrees([r]),{expression:r}}function c(e,n,r){if(e===void 0)return{};if(!Object.values(i).includes(e))throw TypeError(`${t.constantName(n)} group scope is invalid.`);if(e===`root`&&r.expression)throw TypeError(`${t.constantName(n)} with a ROOT scope requires a field input.`);return{scope:e}}var l={terms(e,t,{missingKey:r,scope:i}={}){if(r!==void 0&&(typeof r!=`string`||!r.trim()))throw TypeError(`terms missingKey must not be blank.`);let a=s(e,`terms`);if(r!==void 0&&a.expression)throw TypeError(`terms missingKey requires a field input.`);return{type:`terms`,...r===void 0?{}:{missingKey:r},...a,...c(i,`terms`,a),alias:n.aggregationAlias(t)}},histogram(e,t,{interval:r,scope:i}){if(!Number.isFinite(r)||r<=0)throw TypeError(`histogram interval must be finite and greater than 0.`);let a=s(e,`histogram`);return{type:`histogram`,...a,...c(i,`histogram`,a),interval:r,alias:n.aggregationAlias(t)}},dateHistogram(e,t,{unit:r,timeZone:i,dense:o,scope:s}){if(o!==void 0&&typeof o!=`boolean`)throw TypeError(`date histogram dense must be boolean.`);if(!Object.values(a).includes(r))throw TypeError(`date histogram unit is invalid.`);if(i!==void 0&&(typeof i!=`string`||!i.trim()))throw TypeError(`date histogram timeZone cannot be blank.`);return{type:`date-histogram`,...o===void 0?{}:{dense:o},field:n.aggregationField(e),...c(s,`date-histogram`,{}),unit:r,alias:n.aggregationAlias(t),...i===void 0?{}:{timeZone:i}}},datePart(e,t,{part:r,timeZone:i,dense:a,scope:s}){if(a!==void 0&&typeof a!=`boolean`)throw TypeError(`date part dense must be boolean.`);if(!Object.values(o).includes(r))throw TypeError(`date part is invalid.`);if(i!==void 0&&(typeof i!=`string`||!i.trim()))throw TypeError(`date part timeZone cannot be blank.`);return{type:`date-part`,...a===void 0?{}:{dense:a},field:n.aggregationField(e),...c(s,`date-part`,{}),part:r,alias:n.aggregationAlias(t),...i===void 0?{}:{timeZone:i}}}};exports.AggregationDatePart=o,exports.AggregationDateUnit=a,exports.AggregationGroupScope=i,exports.AggregationGroupType=r,exports.groupBuilders=l,exports.groupInput=s,exports.groupScope=c;
|
|
2
|
+
//# sourceMappingURL=groups.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups.cjs","names":["aggregationField","constantName","aggregationAlias","require_expressionTrees","require_constantName","require_aliases","AggregationGroupType","\"TERMS\"","\"HISTOGRAM\"","\"DATE_HISTOGRAM\"","\"DATE_PART\"","AggregationGroupScope","\"ELEMENT\"","\"ROOT\"","AggregationDateUnit","\"YEAR\"","\"QUARTER\"","\"MONTH\"","\"WEEK\"","\"DAY\"","\"HOUR\"","\"MINUTE\"","\"SECOND\"","AggregationDatePart","\"DAY_OF_WEEK\"","\"DAY_OF_MONTH\"","\"HOUR_OF_DAY\"","\"MONTH_OF_YEAR\"","groupInput","input","type","groupScope","scope","source","groupBuilders","missingKey","alias","interval","dense","unit","timeZone","field","part"],"sources":["../../../src/dsl/aggregation/groups.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 { constantName } from '../constantName.js';\nimport type { QueryField } from '../filter/index.js';\nimport { aggregationField } from './aliases.js';\nimport { requireValidExpressionTrees } from './expressionTrees.js';\nimport type { AggregationExpression } from './types.js';\nimport { aggregationAlias } from './aliases.js';\n\n/** The kind of an {@link AggregationGroup}, sent as its `type`. */\nexport enum AggregationGroupType {\n /** One group per distinct value; {@link groupBuilders.terms | `aggregation.terms`}. */\n TERMS = 'terms',\n /** Number buckets of equal width; {@link groupBuilders.histogram | `aggregation.histogram`}. */\n HISTOGRAM = 'histogram',\n /** Calendar buckets of a time field; {@link groupBuilders.dateHistogram | `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 groupBuilders.datePart | `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 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/** 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 groupBuilders.terms | `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 groupBuilders.histogram | `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 groupBuilders.dateHistogram | `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 groupBuilders.datePart | `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 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 groupBuilders.terms | `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 groupBuilders.histogram | `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 groupBuilders.dateHistogram | `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. Sent only when set; the server reads none as `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 groupBuilders.datePart | `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. Sent only when set; the server reads none as `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/**\n * The input of a TERMS or HISTOGRAM group: a field path, or an expression in\n * its place, never both, as Wow's `requireGroupInput` has it.\n */\nexport function groupInput<FIELDS extends string>(\n input: FIELDS | AggregationExpression<FIELDS>,\n type: string,\n): AggregationGroupInput<FIELDS> {\n if (typeof input === 'string') return { field: aggregationField(input) };\n if (input === null || typeof input !== 'object') {\n throw new TypeError(\n `${constantName(type)} group requires exactly one of field and expression.`,\n );\n }\n requireValidExpressionTrees([input]);\n return { expression: input };\n}\n\n/** A group's `scope`, sent only when given; `ROOT` needs a field input. */\nexport function groupScope(\n scope: AggregationGroupScope | undefined,\n type: string,\n source: { expression?: unknown },\n): { scope?: AggregationGroupScope } {\n if (scope === undefined) return {};\n if (!Object.values(AggregationGroupScope).includes(scope)) {\n throw new TypeError(`${constantName(type)} group scope is invalid.`);\n }\n if (scope === AggregationGroupScope.ROOT && source.expression) {\n throw new TypeError(\n `${constantName(type)} with a ROOT scope requires a field input.`,\n );\n }\n return { scope };\n}\n\n/** The builders of the groups of an aggregation query: terms, histograms, date histograms and date parts. */\nexport const groupBuilders = {\n /**\n * Groups by each distinct value of a field, or of a computed expression.\n * `{ type: 'terms', field, alias, missingKey? }`, or\n * `{ type: 'terms', expression, alias }`.\n *\n * @param input - The field to group by, or an expression in its place\n * (Wow 9.2 and later, an expensive computation).\n * @param alias - The name of the group column in the result rows.\n * @param options.missingKey - The key of the rows without a value; only\n * with a field.\n * @param options.scope - What the field is relative to when the query\n * expands elements: `ROOT` groups the elements by a field of their root\n * record. Wow 9.9 and later.\n * @throws TypeError when `input` or `alias` is invalid, `missingKey` is\n * blank, or `missingKey` is given with an expression.\n * @example\n * ```typescript\n * aggregation.terms('state.status', 'status', { missingKey: 'NONE' });\n * aggregation.terms(\n * aggregation.dateDiff('state.paidAt', 'state.shippedAt', DateDiffUnit.DAY),\n * 'daysToShip',\n * );\n * ```\n */\n terms<FIELDS extends string>(\n input: FIELDS | AggregationExpression<FIELDS>,\n alias: string,\n { missingKey, scope }: TermsAggregationOptions = {},\n ): TermsAggregationGroup<FIELDS> {\n if (\n missingKey !== undefined &&\n (typeof missingKey !== 'string' || !missingKey.trim())\n ) {\n throw new TypeError('terms missingKey must not be blank.');\n }\n const source = groupInput(input, 'terms');\n if (missingKey !== undefined && source.expression) {\n throw new TypeError('terms missingKey requires a field input.');\n }\n return {\n type: AggregationGroupType.TERMS,\n ...(missingKey === undefined ? {} : { missingKey }),\n ...source,\n ...groupScope(scope, 'terms', source),\n alias: aggregationAlias(alias),\n };\n },\n /**\n * Groups a number field, or a computed expression, into buckets of equal\n * width. `{ type: 'histogram', field | expression, interval, alias }`.\n *\n * @param input - The number field to bucket, or an expression in its\n * place (Wow 9.2 and later, an expensive computation).\n * @param alias - The name of the bucket column in the result rows.\n * @param options.interval - The bucket width.\n * @param options.scope - What the field is relative to when the query\n * expands elements: `ROOT` groups the elements by a field of their root\n * record. Wow 9.9 and later.\n * @throws TypeError when `interval` is not finite and greater than 0, or\n * `field` or `alias` is invalid.\n * @example\n * ```typescript\n * aggregation.histogram('state.amount', 'amountBand', { interval: 100 });\n * ```\n */\n histogram<FIELDS extends string>(\n input: FIELDS | AggregationExpression<FIELDS>,\n alias: string,\n { interval, scope }: HistogramAggregationOptions,\n ): HistogramAggregationGroup<FIELDS> {\n if (!Number.isFinite(interval) || interval <= 0) {\n throw new TypeError(\n 'histogram interval must be finite and greater than 0.',\n );\n }\n const source = groupInput(input, 'histogram');\n return {\n type: AggregationGroupType.HISTOGRAM,\n ...source,\n ...groupScope(scope, 'histogram', source),\n interval,\n alias: aggregationAlias(alias),\n };\n },\n /**\n * Groups a time field into calendar buckets.\n * `{ type: 'date-histogram', field, unit, alias, timeZone?, dense? }`.\n *\n * @param field - The time field (epoch milliseconds) to bucket.\n * @param alias - The name of the bucket column in the result rows.\n * @param options.unit - The calendar unit of a bucket.\n * @param options.timeZone - The zone buckets are cut in. Sent only when\n * set; the server reads none as `UTC`.\n * @param options.dense - Whether the empty buckets of the range are filled\n * in.\n * @param options.scope - What the field is relative to when the query\n * expands elements: `ROOT` groups the elements by a field of their root\n * record. Wow 9.9 and later.\n * @throws TypeError when `unit` is not an `AggregationDateUnit`,\n * `timeZone` is blank, `dense` is not a boolean, or `field` or `alias` is\n * invalid.\n * @example\n * ```typescript\n * aggregation.dateHistogram('createTime', 'day', {\n * unit: AggregationDateUnit.DAY,\n * timeZone: 'Asia/Shanghai',\n * });\n * ```\n */\n dateHistogram<FIELDS extends string>(\n field: FIELDS,\n alias: string,\n { unit, timeZone, dense, scope }: DateHistogramAggregationOptions,\n ): DateHistogramAggregationGroup<FIELDS> {\n if (dense !== undefined && typeof dense !== 'boolean') {\n throw new TypeError('date histogram dense must be boolean.');\n }\n if (!Object.values(AggregationDateUnit).includes(unit)) {\n throw new TypeError('date histogram unit is invalid.');\n }\n if (\n timeZone !== undefined &&\n (typeof timeZone !== 'string' || !timeZone.trim())\n ) {\n throw new TypeError('date histogram timeZone cannot be blank.');\n }\n return {\n type: AggregationGroupType.DATE_HISTOGRAM,\n ...(dense === undefined ? {} : { dense }),\n field: aggregationField(field),\n ...groupScope(scope, 'date-histogram', {}),\n unit,\n alias: aggregationAlias(alias),\n ...(timeZone === undefined ? {} : { timeZone }),\n };\n },\n /**\n * Groups a time field by one calendar part of each instant, such as the\n * weekday or the hour, so records from different days share a bucket.\n * `{ type: 'date-part', field, part, alias, timeZone?, dense? }`.\n *\n * The group's keys in the result rows are integers: `DAY_OF_WEEK` is the\n * ISO weekday, 1 (Monday) to 7 (Sunday); `DAY_OF_MONTH` 1 to 31;\n * `HOUR_OF_DAY` 0 to 23 on the wall clock of `timeZone`; `MONTH_OF_YEAR`\n * 1 to 12. With `dense`, every key of that domain comes back, those\n * without records carrying each metric's empty value; `dense` needs the\n * group to be the query's only one. Wow 9.2 and later.\n *\n * @param field - The time field (epoch milliseconds) to read the part of.\n * @param alias - The name of the part column in the result rows.\n * @param options.part - The calendar part to group by.\n * @param options.timeZone - The zone the part is read in. Sent only when\n * set; the server reads none as `UTC`.\n * @param options.dense - Whether every key of the part's domain is\n * returned.\n * @param options.scope - What the field is relative to when the query\n * expands elements: `ROOT` groups the elements by a field of their root\n * record. Wow 9.9 and later.\n * @throws TypeError when `part` is not an `AggregationDatePart`,\n * `timeZone` is blank, `dense` is not a boolean, or `field` or `alias` is\n * invalid.\n * @example\n * ```typescript\n * aggregation.datePart('createTime', 'weekday', {\n * part: AggregationDatePart.DAY_OF_WEEK,\n * timeZone: 'Asia/Shanghai',\n * });\n * ```\n */\n datePart<FIELDS extends string>(\n field: FIELDS,\n alias: string,\n { part, timeZone, dense, scope }: DatePartAggregationOptions,\n ): DatePartAggregationGroup<FIELDS> {\n if (dense !== undefined && typeof dense !== 'boolean') {\n throw new TypeError('date part dense must be boolean.');\n }\n if (!Object.values(AggregationDatePart).includes(part)) {\n throw new TypeError('date part is invalid.');\n }\n if (\n timeZone !== undefined &&\n (typeof timeZone !== 'string' || !timeZone.trim())\n ) {\n throw new TypeError('date part timeZone cannot be blank.');\n }\n return {\n type: AggregationGroupType.DATE_PART,\n ...(dense === undefined ? {} : { dense }),\n field: aggregationField(field),\n ...groupScope(scope, 'date-part', {}),\n part,\n alias: aggregationAlias(alias),\n ...(timeZone === undefined ? {} : { timeZone }),\n };\n },\n};\n"],"mappings":"A,qGAqBA,IAAYM,EAAL,SAAA,EAAA,C,MAEL,GAAAC,MAAA,QAEA,EAAAC,UAAA,YAEA,EAAAC,eAAA,iBAKA,EAAAC,UAAA,Y,CACF,EAAA,CAAA,CAAA,EAMYC,EAAL,SAAA,EAAA,C,MAEL,GAAAC,QAAA,UAEA,EAAAC,KAAA,O,CACF,EAAA,CAAA,CAAA,EAMYC,EAAL,SAAA,EAAA,C,MACL,GAAAC,KAAA,OACA,EAAAC,QAAA,UACA,EAAAC,MAAA,QACA,EAAAC,KAAA,OACA,EAAAC,IAAA,MACA,EAAAC,KAAA,OACA,EAAAC,OAAA,SACA,EAAAC,OAAA,S,CACF,EAAA,CAAA,CAAA,EAOYC,EAAL,SAAA,EAAA,C,MAEL,GAAAC,YAAA,cAKA,EAAAC,aAAA,eAEA,EAAAC,YAAA,cAEA,EAAAC,cAAA,gB,CACF,EAAA,CAAA,CAAA,EAgLA,SAAgBC,EACd,EACA,EAC+B,CAC/B,GAAI,OAAOC,GAAU,SAAU,MAAO,CAAE,MAAO7B,EAAAA,iBAAiB6B,CAAK,CAAE,EACvE,GAAsB,OAAOA,GAAU,WAAnCA,EACF,MAAU,UACR,GAAG5B,EAAAA,aAAa6B,CAAI,EAAE,qDACxB,EAGF,OADA3B,EAAA,4BAA4B,CAAC0B,CAAK,CAAC,EAC5B,CAAE,WAAYA,CAAM,CAC7B,CAGA,SAAgBE,EACd,EACA,EACA,EACmC,CACnC,GAAIC,IAAU,IAAA,GAAW,MAAO,CAAC,EACjC,GAAI,CAAC,OAAO,OAAOrB,CAAqB,CAAC,CAAC,SAASqB,CAAK,EACtD,MAAU,UAAU,GAAG/B,EAAAA,aAAa6B,CAAI,EAAE,yBAAyB,EAErE,GAAIE,IAAA,QAAwCC,EAAO,WACjD,MAAU,UACR,GAAGhC,EAAAA,aAAa6B,CAAI,EAAE,2CACxB,EAEF,MAAO,CAAE,OAAM,CACjB,CAGA,IAAaI,EAAgB,CAyB3B,MACE,EACA,EACA,CAAE,aAAY,SAAmC,CAAC,EACnB,CAC/B,GACEC,IAAe,IAAA,KACd,OAAOA,GAAe,UAAY,CAACA,EAAW,KAAK,GAEpD,MAAU,UAAU,qCAAqC,EAE3D,IAAMF,EAASL,EAAWC,EAAO,OAAO,EACxC,GAAIM,IAAe,IAAA,IAAaF,EAAO,WACrC,MAAU,UAAU,0CAA0C,EAEhE,MAAO,CACL,KAAA,QACA,GAAIE,IAAe,IAAA,GAAY,CAAC,EAAI,CAAE,YAAW,EACjD,GAAGF,EACH,GAAGF,EAAWC,EAAO,QAASC,CAAM,EACpC,MAAO/B,EAAAA,iBAAiBkC,CAAK,CAC/B,CACF,EAmBA,UACE,EACA,EACA,CAAE,WAAU,SACuB,CACnC,GAAI,CAAC,OAAO,SAASC,CAAQ,GAAKA,GAAY,EAC5C,MAAU,UACR,uDACF,EAEF,IAAMJ,EAASL,EAAWC,EAAO,WAAW,EAC5C,MAAO,CACL,KAAA,YACA,GAAGI,EACH,GAAGF,EAAWC,EAAO,YAAaC,CAAM,EACxC,WACA,MAAO/B,EAAAA,iBAAiBkC,CAAK,CAC/B,CACF,EA0BA,cACE,EACA,EACA,CAAE,OAAM,WAAU,QAAO,SACc,CACvC,GAAIE,IAAU,IAAA,IAAa,OAAOA,GAAU,UAC1C,MAAU,UAAU,uCAAuC,EAE7D,GAAI,CAAC,OAAO,OAAOxB,CAAmB,CAAC,CAAC,SAASyB,CAAI,EACnD,MAAU,UAAU,iCAAiC,EAEvD,GACEC,IAAa,IAAA,KACZ,OAAOA,GAAa,UAAY,CAACA,EAAS,KAAK,GAEhD,MAAU,UAAU,0CAA0C,EAEhE,MAAO,CACL,KAAA,iBACA,GAAIF,IAAU,IAAA,GAAY,CAAC,EAAI,CAAE,OAAM,EACvC,MAAOtC,EAAAA,iBAAiByC,CAAK,EAC7B,GAAGV,EAAWC,EAAO,iBAAkB,CAAC,CAAC,EACzC,OACA,MAAO9B,EAAAA,iBAAiBkC,CAAK,EAC7B,GAAII,IAAa,IAAA,GAAY,CAAC,EAAI,CAAE,UAAS,CAC/C,CACF,EAkCA,SACE,EACA,EACA,CAAE,OAAM,WAAU,QAAO,SACS,CAClC,GAAIF,IAAU,IAAA,IAAa,OAAOA,GAAU,UAC1C,MAAU,UAAU,kCAAkC,EAExD,GAAI,CAAC,OAAO,OAAOf,CAAmB,CAAC,CAAC,SAASmB,CAAI,EACnD,MAAU,UAAU,uBAAuB,EAE7C,GACEF,IAAa,IAAA,KACZ,OAAOA,GAAa,UAAY,CAACA,EAAS,KAAK,GAEhD,MAAU,UAAU,qCAAqC,EAE3D,MAAO,CACL,KAAA,YACA,GAAIF,IAAU,IAAA,GAAY,CAAC,EAAI,CAAE,OAAM,EACvC,MAAOtC,EAAAA,iBAAiByC,CAAK,EAC7B,GAAGV,EAAWC,EAAO,YAAa,CAAC,CAAC,EACpC,OACA,MAAO9B,EAAAA,iBAAiBkC,CAAK,EAC7B,GAAII,IAAa,IAAA,GAAY,CAAC,EAAI,CAAE,UAAS,CAC/C,CACF,CACF,E"}
|