@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":"types.es.js","names":["AggregationGroupType","\"TERMS\"","\"HISTOGRAM\"","\"DATE_HISTOGRAM\"","\"DATE_PART\"","AggregationGroupScope","\"ELEMENT\"","\"ROOT\"","AggregationMetricType","\"COUNT\"","\"NUMERIC\"","\"ANY\"","\"DISTINCT_COUNT\"","\"PERCENTILE\"","\"DERIVED\"","\"FIRST\"","\"LAST\"","AggregationExpressionType","\"FIELD\"","\"CONSTANT\"","\"BINARY\"","\"DATE_DIFF\"","DateDiffUnit","\"SECOND\"","\"MINUTE\"","\"HOUR\"","\"DAY\"","AggregationExpressionOperator","\"ADD\"","\"SUBTRACT\"","\"MULTIPLY\"","\"DIVIDE\"","AggregationDateUnit","\"YEAR\"","\"QUARTER\"","\"MONTH\"","\"WEEK\"","AggregationDatePart","\"DAY_OF_WEEK\"","\"DAY_OF_MONTH\"","\"HOUR_OF_DAY\"","\"MONTH_OF_YEAR\"","AggregationFunction","\"SUM\"","\"AVG\"","\"MIN\"","\"MAX\"","\"STDDEV\"","\"VARIANCE\"","DerivedExpressionType","\"METRIC_REF\"","\"TOTAL\"","\"RUNNING\"","\"PREVIOUS\"","\"RANK\"","WindowFunction","RunningFunction","HavingExpressionType","\"CONDITION\"","\"BETWEEN\"","\"IN\"","\"IS_NULL\"","\"AND\"","\"OR\"","ComparisonOperator","\"EQ\"","\"NE\"","\"GT\"","\"GTE\"","\"LT\"","\"LTE\"","AGGREGATION_LIMITS"],"sources":["../../../src/dsl/aggregation/types.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ElementFilterExpression,\n FilterExpression,\n QueryField,\n ExpressionFilter,\n} from '../filter/index.js';\nimport type { FieldSort, SortDirection } from '../sort.js';\n\n/** The kind of an {@link AggregationGroup}, sent as its `type`. */\nexport enum AggregationGroupType {\n /** One group per distinct value; {@link aggregation.terms}. */\n TERMS = 'terms',\n /** Number buckets of equal width; {@link aggregation.histogram}. */\n HISTOGRAM = 'histogram',\n /** Calendar buckets of a time field; {@link aggregation.dateHistogram}. */\n DATE_HISTOGRAM = 'date-histogram',\n /**\n * One calendar part of a time field, such as the weekday or the hour;\n * {@link aggregation.datePart}. Wow 9.2 and later.\n */\n DATE_PART = 'date-part',\n}\n\n/**\n * What an {@link AggregationGroup}'s field is relative to when the query\n * expands elements, sent as its `scope`. Wow 9.9 and later.\n */\nexport enum AggregationGroupScope {\n /** The innermost expanded element; the default. */\n ELEMENT = 'element',\n /** The root record, so the elements are grouped by a field of their root. */\n ROOT = 'root',\n}\n\n/**\n * The kind of an {@link AggregationMetric}, sent as its `type`. Wow 8.12\n * knows `COUNT` and `NUMERIC`, Wow 9.0 adds `ANY`, and the other three need\n * Wow 9.1.\n */\nexport enum AggregationMetricType {\n /** The number of rows; {@link aggregation.count}. */\n COUNT = 'count',\n /**\n * An {@link AggregationFunction} of an expression; {@link aggregation.sum}\n * and its siblings.\n */\n NUMERIC = 'numeric',\n /** Any one value of a field; {@link aggregation.any}. Wow 9.0 and later. */\n ANY = 'any',\n /**\n * The number of distinct values; {@link aggregation.distinctCount}. Wow 9.1\n * and later.\n */\n DISTINCT_COUNT = 'distinct-count',\n /**\n * A percentile of an expression; {@link aggregation.percentile}. Wow 9.1\n * and later.\n */\n PERCENTILE = 'percentile',\n /**\n * Arithmetic over other metrics; {@link aggregation.derived}. Wow 9.1 and\n * later.\n */\n DERIVED = 'derived',\n /**\n * A field's value on the group's earliest record; {@link aggregation.first}.\n * Wow 9.2 and later.\n */\n FIRST = 'first',\n /**\n * A field's value on the group's latest record; {@link aggregation.last}.\n * Wow 9.2 and later.\n */\n LAST = 'last',\n}\n\n/** The kind of an {@link AggregationExpression} node, sent as its `type`. */\nexport enum AggregationExpressionType {\n /** The value of a field; {@link aggregation.field}. */\n FIELD = 'field',\n /** A number; {@link aggregation.constant}. */\n CONSTANT = 'constant',\n /** Two operands and an {@link AggregationExpressionOperator}. */\n BINARY = 'binary',\n /**\n * The time elapsed between two time fields; {@link aggregation.dateDiff}.\n * Wow 9.2 and later.\n */\n DATE_DIFF = 'date-diff',\n}\n\n/**\n * The unit a `DATE_DIFF` measures elapsed time in. Each has a fixed length:\n * a `DAY` is exactly 24 hours, and months and years, whose length depends on\n * a calendar and a time zone, are not offered.\n */\nexport enum DateDiffUnit {\n SECOND = 'second',\n MINUTE = 'minute',\n HOUR = 'hour',\n DAY = 'day',\n}\n\n/**\n * The arithmetic of a `BINARY` node, in an {@link AggregationExpression} or a\n * {@link DerivedExpression}.\n */\nexport enum AggregationExpressionOperator {\n /** `left + right` */\n ADD = 'add',\n /** `left - right` */\n SUBTRACT = 'subtract',\n /** `left * right` */\n MULTIPLY = 'multiply',\n /** `left / right` */\n DIVIDE = 'divide',\n}\n\n/**\n * The calendar unit of a `DATE_HISTOGRAM` bucket, cut in the group's\n * `timeZone`.\n */\nexport enum AggregationDateUnit {\n YEAR = 'year',\n QUARTER = 'quarter',\n MONTH = 'month',\n WEEK = 'week',\n DAY = 'day',\n HOUR = 'hour',\n MINUTE = 'minute',\n SECOND = 'second',\n}\n\n/**\n * The calendar part a `DATE_PART` group takes of each instant, read in the\n * group's `timeZone`. Its keys are integers from a fixed domain, so records\n * from different days, weeks or years fall into one bucket.\n */\nexport enum AggregationDatePart {\n /** The ISO weekday: 1 is Monday, 7 is Sunday. */\n DAY_OF_WEEK = 'day-of-week',\n /**\n * The day of the month, 1 to 31; days 29 to 31 exist only in the months\n * that have them.\n */\n DAY_OF_MONTH = 'day-of-month',\n /** The hour on the wall clock of the group's `timeZone`, 0 to 23. */\n HOUR_OF_DAY = 'hour-of-day',\n /** The month of the year, 1 (January) to 12. */\n MONTH_OF_YEAR = 'month-of-year',\n}\n\n/**\n * What a `NUMERIC` metric computes over its expression; each has a builder,\n * {@link aggregation.sum} through {@link aggregation.variance}.\n */\nexport enum AggregationFunction {\n /** The sum */\n SUM = 'sum',\n /** The average */\n AVG = 'avg',\n /** The least value */\n MIN = 'min',\n /** The greatest value */\n MAX = 'max',\n /** The standard deviation */\n STDDEV = 'stddev',\n /** The variance */\n VARIANCE = 'variance',\n}\n\n/**\n * An array field whose elements the query aggregates over instead of the\n * root documents; build it with {@link aggregation.element}. A query takes at\n * most `AGGREGATION_LIMITS.MAX_ELEMENTS` of them.\n */\nexport interface AggregationElement {\n /** The array field, a query field path. */\n path: QueryField;\n /**\n * Keeps only the elements that match; no root filters and no search, but\n * an `EXPRESSION` filter may compare an element's computed value.\n */\n filter?: ElementFilterExpression | ExpressionFilter;\n}\n\n/** What every {@link AggregationGroup} has. */\ninterface AggregationGroupBase<FIELDS extends string = string> {\n /** The field the rows are grouped by. */\n field: QueryField<FIELDS>;\n /** The name of the group's column in the result rows. */\n alias: string;\n /**\n * What `field` is relative to when the query expands elements: the\n * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).\n * A `ROOT` group names a field, never an expression. Wow 9.9 and later,\n * where `analysis.rootGroups` is `true`.\n */\n scope?: AggregationGroupScope;\n}\n\n/**\n * What a TERMS or HISTOGRAM group groups by: a field, or a computed\n * expression in its place (Wow 9.2 and later), never both. An expression\n * input is an expensive computation the server admits only where\n * `analysis.expressions` is `true`.\n */\nexport type AggregationGroupInput<FIELDS extends string = string> =\n | {\n /** The field the rows are grouped by. */\n field: QueryField<FIELDS>;\n expression?: undefined;\n }\n | {\n field?: undefined;\n /** The per-row value the rows are grouped by, such as a `DATE_DIFF`. */\n expression: AggregationExpression<FIELDS>;\n };\n\n/**\n * One group per distinct value of a field, or of an expression;\n * {@link aggregation.terms}. `missingKey` needs a field.\n */\nexport type TermsAggregationGroup<FIELDS extends string = string> = {\n type: AggregationGroupType.TERMS;\n /** The name of the group's column in the result rows. */\n alias: string;\n /** The key the rows without a value are grouped under. Wow 9.1 and later. */\n missingKey?: string;\n /**\n * What `field` is relative to when the query expands elements: the\n * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).\n * A `ROOT` group names a field, never an expression. Wow 9.9 and later,\n * where `analysis.rootGroups` is `true`.\n */\n scope?: AggregationGroupScope;\n} & AggregationGroupInput<FIELDS>;\n\n/**\n * Buckets of equal width over a number field, or over an expression;\n * {@link aggregation.histogram}.\n */\nexport type HistogramAggregationGroup<FIELDS extends string = string> = {\n type: AggregationGroupType.HISTOGRAM;\n /** The name of the group's column in the result rows. */\n alias: string;\n /** The width of each bucket, greater than 0. */\n interval: number;\n /**\n * What `field` is relative to when the query expands elements: the\n * innermost element (`ELEMENT`, the default) or the root record (`ROOT`).\n * A `ROOT` group names a field, never an expression. Wow 9.9 and later,\n * where `analysis.rootGroups` is `true`.\n */\n scope?: AggregationGroupScope;\n} & AggregationGroupInput<FIELDS>;\n\n/**\n * Calendar buckets over a time field in epoch milliseconds;\n * {@link aggregation.dateHistogram}.\n */\nexport interface DateHistogramAggregationGroup<\n FIELDS extends string = string,\n> extends AggregationGroupBase<FIELDS> {\n type: AggregationGroupType.DATE_HISTOGRAM;\n /** The calendar unit of each bucket. */\n unit: AggregationDateUnit;\n /** The IANA zone the buckets are cut in; `UTC` when absent. */\n timeZone?: string;\n /**\n * Whether the server fills in the empty buckets of the range. Wow 9.1 and\n * later, and only when this is the query's only group.\n */\n dense?: boolean;\n}\n\n/**\n * One calendar part of a time field in epoch milliseconds, such as the\n * weekday or the hour; {@link aggregation.datePart}. Its keys in the result\n * rows are integers from the part's domain, such as 1 (Monday) to 7 (Sunday)\n * for `DAY_OF_WEEK`. Wow 9.2 and later.\n */\nexport interface DatePartAggregationGroup<\n FIELDS extends string = string,\n> extends AggregationGroupBase<FIELDS> {\n type: AggregationGroupType.DATE_PART;\n /** The calendar part each row is grouped by. */\n part: AggregationDatePart;\n /** The IANA zone the part is read in; `UTC` when absent. */\n timeZone?: string;\n /**\n * Whether the server returns every key of the part's domain, filling a\n * key with no records with each metric's empty value. Only when this is\n * the query's only group.\n */\n dense?: boolean;\n}\n\n/**\n * One dimension of an {@link AggregationQuery}'s `groupBy`: each result row\n * is one combination of the groups' keys.\n */\nexport type AggregationGroup<FIELDS extends string = string> =\n | TermsAggregationGroup<FIELDS>\n | HistogramAggregationGroup<FIELDS>\n | DateHistogramAggregationGroup<FIELDS>\n | DatePartAggregationGroup<FIELDS>;\n\n/** The value of a field, as an operand; {@link aggregation.field}. */\nexport interface FieldAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.FIELD;\n /** The field, a query field path. */\n field: QueryField<FIELDS>;\n}\n\n/** A number, as an operand; {@link aggregation.constant}. */\nexport interface ConstantAggregationExpression {\n type: AggregationExpressionType.CONSTANT;\n /** A finite number. */\n value: number;\n}\n\n/**\n * `left operator right`; {@link aggregation.add}, {@link aggregation.subtract},\n * {@link aggregation.multiply}, {@link aggregation.divide}.\n */\nexport interface BinaryAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.BINARY;\n /** The arithmetic. */\n operator: AggregationExpressionOperator;\n /** The left operand. */\n left: AggregationExpression<FIELDS>;\n /** The right operand. */\n right: AggregationExpression<FIELDS>;\n}\n\n/**\n * The time from the instant in `from` to the instant in `to`, `to − from`,\n * in `unit`, as a signed decimal: negative when `to` is earlier, and no\n * value when either is absent. Both are single-valued time fields (their\n * `aggregate.groups` list `DATE_HISTOGRAM`), each read in its own encoding;\n * {@link aggregation.dateDiff}. Wow 9.2 and later.\n */\nexport interface DateDiffAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.DATE_DIFF;\n /** The earlier instant, when the difference is positive. */\n from: QueryField<FIELDS>;\n /** The later instant, when the difference is positive. */\n to: QueryField<FIELDS>;\n /** The unit the difference is measured in. */\n unit: DateDiffUnit;\n}\n\n/**\n * Per-row arithmetic over fields, time differences and numbers, which a\n * metric aggregates, a TERMS or HISTOGRAM group groups by, and an\n * `EXPRESSION` filter compares. A tree at most\n * `AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH` deep and `MAX_EXPRESSION_NODES`\n * large, counted over a query's metrics together and over each group or\n * filter on its own.\n */\nexport type AggregationExpression<FIELDS extends string = string> =\n | FieldAggregationExpression<FIELDS>\n | ConstantAggregationExpression\n | BinaryAggregationExpression<FIELDS>\n | DateDiffAggregationExpression<FIELDS>;\n\n/** The number of rows in each group; {@link aggregation.count}. */\nexport interface CountAggregationMetric<FIELDS extends string = string> {\n /** Counts only the rows that match. Wow 9.1 and later. */\n filter?: FilterExpression<FIELDS>;\n type: AggregationMetricType.COUNT;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/**\n * An {@link AggregationFunction} of an expression; {@link aggregation.sum},\n * `avg`, `min`, `max`, `stddev`, `variance`.\n */\nexport interface NumericAggregationMetric<FIELDS extends string = string> {\n /** Aggregates only the rows that match. Wow 9.1 and later. */\n filter?: FilterExpression<FIELDS>;\n type: AggregationMetricType.NUMERIC;\n /** What is computed. */\n function: AggregationFunction;\n /** The per-row value it is computed over. */\n expression: AggregationExpression<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/**\n * Any one value of a field within each group, of any type;\n * {@link aggregation.any}. Wow 9.0 and later. Neither a derived metric nor\n * `having` may refer to it.\n */\nexport interface AnyAggregationMetric<FIELDS extends string = string> {\n /** Aggregates only the rows that match. Wow 9.1 and later. */\n filter?: FilterExpression<FIELDS>;\n type: AggregationMetricType.ANY;\n /** The field whose value is taken. */\n field: QueryField<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/**\n * A field's value on the earliest (`FIRST`) or latest (`LAST`) record of\n * each group, ordered by `orderBy`; {@link aggregation.first} and\n * {@link aggregation.last}. Wow 9.2 and later.\n *\n * The value comes back in the field's own type, not as a number, and is\n * `null` when no record of the group has both a value and an `orderBy`\n * position. Without `orderBy` the server orders by the model's event time,\n * the field the descriptor names as `analysis.firstLastOrderBy`. Records\n * tied on `orderBy` may yield any one of their values. Like `ANY`, neither a\n * derived metric nor `having` may refer to it.\n */\nexport interface EdgeAggregationMetric<FIELDS extends string = string> {\n type: AggregationMetricType.FIRST | AggregationMetricType.LAST;\n /** The single-valued field whose value is taken. */\n field: QueryField<FIELDS>;\n /**\n * The single-valued, sortable field that orders the records; the model's\n * event time when absent.\n */\n orderBy?: QueryField<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n /** Aggregates only the rows that match. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/**\n * The number of distinct values of an expression;\n * {@link aggregation.distinctCount}. Wow 9.1 and later.\n */\nexport interface DistinctCountAggregationMetric<\n FIELDS extends string = string,\n> {\n type: AggregationMetricType.DISTINCT_COUNT;\n /** The per-row value whose distinct values are counted. */\n expression: AggregationExpression<FIELDS>;\n /** The name of the metric's column in the result rows. */\n alias: string;\n /** Aggregates only the rows that match. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/**\n * A percentile of an expression; {@link aggregation.percentile}. Wow 9.1 and\n * later.\n */\nexport interface PercentileAggregationMetric<FIELDS extends string = string> {\n type: AggregationMetricType.PERCENTILE;\n /** The per-row value the percentile is taken over. */\n expression: AggregationExpression<FIELDS>;\n /** Which percentile, within (0, 100). */\n percentile: number;\n /** The name of the metric's column in the result rows. */\n alias: string;\n /** Aggregates only the rows that match. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/** The kind of a {@link DerivedExpression} node, sent as its `type`. */\nexport enum DerivedExpressionType {\n /** The value of another metric of the row, by its alias. */\n METRIC_REF = 'metric-ref',\n /** A number. */\n CONSTANT = 'constant',\n /** Two operands and an {@link AggregationExpressionOperator}. */\n BINARY = 'binary',\n /** A window: the metric summed over a partition of the groups. */\n TOTAL = 'total',\n /** A window: the metric accumulated along an order, or its moving average. */\n RUNNING = 'running',\n /** A window: the metric of an earlier period along a date group. */\n PREVIOUS = 'previous',\n /** A window: the dense rank of the metric within a partition. */\n RANK = 'rank',\n}\n\n/**\n * The window functions of derived expressions, as a storage declares them in\n * `analysis.windows` of its descriptor.\n */\nexport enum WindowFunction {\n TOTAL = 'total',\n RUNNING = 'running',\n PREVIOUS = 'previous',\n RANK = 'rank',\n}\n\n/** What a `RUNNING` window computes over its frame. */\nexport enum RunningFunction {\n SUM = 'sum',\n AVG = 'avg',\n}\n\n/**\n * A window over the groups of the aggregation. Wow computes it over every\n * group the filter selects, before `having`, `sort` and `limit`; `metric`\n * names a non-derived numeric metric declared before the derived one, and\n * `within`, `order` and `along` name groups of the query. Wow 9.9 and later,\n * where `analysis.windows` lists the function.\n */\nexport type DerivedWindow =\n | {\n type: DerivedExpressionType.TOTAL;\n /** A `COUNT` or `SUM` metric. */\n metric: string;\n /** The partition's group aliases; every group when absent. */\n within?: string[];\n }\n | {\n type: DerivedExpressionType.RUNNING;\n /** A `COUNT` or `SUM` metric for `SUM`; any numeric metric for `AVG`. */\n metric: string;\n /** A group alias or a non-derived numeric metric, with its direction. */\n order: FieldSort;\n within?: string[];\n /** The last this many groups; every group up to this one when absent. */\n frame?: number;\n /** `SUM` when absent. */\n function?: RunningFunction;\n }\n | {\n type: DerivedExpressionType.PREVIOUS;\n metric: string;\n /** The alias of a `DATE_HISTOGRAM` group. */\n along: string;\n /** How many steps back; 1 when absent. */\n shift?: number;\n /** Step by this calendar period instead of by one bucket of `along`. */\n period?: AggregationDateUnit;\n }\n | {\n type: DerivedExpressionType.RANK;\n metric: string;\n within?: string[];\n /** `DESC` when absent. */\n direction?: SortDirection;\n };\n\n/**\n * Post-aggregation arithmetic; references must name earlier metrics that are\n * not `ANY`, `FIRST` or `LAST`.\n */\nexport type DerivedExpression =\n | { type: DerivedExpressionType.METRIC_REF; metric: string }\n | { type: DerivedExpressionType.CONSTANT; value: number }\n | {\n type: DerivedExpressionType.BINARY;\n operator: AggregationExpressionOperator;\n left: DerivedExpression;\n right: DerivedExpression;\n }\n | DerivedWindow;\n\n/**\n * A metric computed from metrics declared before it in the same query, after\n * aggregation; {@link aggregation.derived}. Wow 9.1 and later.\n */\nexport interface DerivedAggregationMetric {\n type: AggregationMetricType.DERIVED;\n /** The arithmetic over the other metrics. */\n expression: DerivedExpression;\n /** The name of the metric's column in the result rows. */\n alias: string;\n}\n\n/** The kind of a {@link HavingExpression} node, sent as its `type`. */\nexport enum HavingExpressionType {\n /** A metric compared with a number; `aggregation.having.eq` … `lte`. */\n CONDITION = 'condition',\n /** A metric within bounds, inclusive; `aggregation.having.between`. */\n BETWEEN = 'between',\n /** A metric equal to one of the numbers; `aggregation.having.isIn`. */\n IN = 'in',\n /**\n * A metric without a value, or with one when `negated`;\n * `aggregation.having.isNull`, `isNotNull`.\n */\n IS_NULL = 'is-null',\n /** All operands hold; `aggregation.having.and`. */\n AND = 'and',\n /** At least one operand holds; `aggregation.having.or`. */\n OR = 'or',\n}\n\n/** The comparison of a `CONDITION` in a {@link HavingExpression}. */\nexport enum ComparisonOperator {\n /** `=` */\n EQ = 'eq',\n /** `≠` */\n NE = 'ne',\n /** `>` */\n GT = 'gt',\n /** `≥` */\n GTE = 'gte',\n /** `<` */\n LT = 'lt',\n /** `≤` */\n LTE = 'lte',\n}\n\n/**\n * Filters grouped results by metric aliases, before sorting/limit; never an\n * `ANY`, `FIRST` or `LAST` metric.\n */\nexport type HavingExpression =\n | {\n type: HavingExpressionType.CONDITION;\n metric: string;\n operator: ComparisonOperator;\n value: number;\n }\n | {\n type: HavingExpressionType.BETWEEN;\n metric: string;\n lower: number;\n upper: number;\n }\n | {\n type: HavingExpressionType.IN;\n metric: string;\n values: [number, ...number[]];\n }\n | { type: HavingExpressionType.IS_NULL; metric: string; negated?: boolean }\n | {\n type: HavingExpressionType.AND | HavingExpressionType.OR;\n operands: [HavingExpression, ...HavingExpression[]];\n };\n\n/**\n * One column an {@link AggregationQuery} computes for each group; a query\n * takes 1 to `AGGREGATION_LIMITS.MAX_METRICS` of them.\n */\nexport type AggregationMetric<FIELDS extends string = string> =\n | CountAggregationMetric<FIELDS>\n | NumericAggregationMetric<FIELDS>\n | AnyAggregationMetric<FIELDS>\n | DistinctCountAggregationMetric<FIELDS>\n | PercentileAggregationMetric<FIELDS>\n | DerivedAggregationMetric\n | EdgeAggregationMetric<FIELDS>;\n\n/**\n * An aggregation request: which documents, grouped how, computing which\n * metrics. `QueryModelClient.aggregate` sends it, and each\n * result row holds the groups' and metrics' columns by alias. Assemble it\n * with {@link aggregation.query}, which checks the rules Wow enforces across\n * its parts before anything is sent.\n *\n * Wow 8.11 has no aggregation endpoint; Wow 8.12 added it with `COUNT` and\n * `NUMERIC` metrics, and Wow 9.0 added `ANY`. `having`, the `DISTINCT_COUNT`,\n * `PERCENTILE` and `DERIVED` metrics, metric filters, `missingKey` and `dense`\n * need Wow 9.1.\n *\n * @template ROOT_FIELDS - The fields `filter` may name\n * @template AGGREGATION_FIELDS - The fields groups and metrics may name\n */\nexport interface AggregationQuery<\n ROOT_FIELDS extends string = string,\n AGGREGATION_FIELDS extends string = ROOT_FIELDS,\n> {\n /** Which documents are aggregated; all of them when absent. */\n filter?: FilterExpression<ROOT_FIELDS>;\n /** Array fields to aggregate the elements of, instead of the documents. */\n elements?: AggregationElement[];\n /** The dimensions of the result; one row in total when absent or empty. */\n groupBy?: AggregationGroup<AGGREGATION_FIELDS>[];\n /** The columns computed for each group. */\n metrics: [\n AggregationMetric<AGGREGATION_FIELDS>,\n ...AggregationMetric<AGGREGATION_FIELDS>[],\n ];\n /**\n * The order of the rows, by group or metric alias; needs a `groupBy`. Wow\n * then sorts by each remaining group ascending.\n */\n sort?: FieldSort[];\n /**\n * The most rows returned, 1 to `AGGREGATION_LIMITS.MAX_LIMIT`; the\n * server returns `DEFAULT_LIMIT` (100) when absent.\n */\n limit?: number;\n /**\n * Keeps only the grouped rows whose metrics match, before `sort` and\n * `limit`; built with {@link aggregation.having}. Needs a `groupBy`.\n */\n having?: HavingExpression;\n}\n\n/**\n * The options every metric builder takes after its target and alias.\n */\nexport interface AggregationMetricOptions<FIELDS extends string = string> {\n /** Counts only the rows that match; sent as the metric's `filter`. */\n filter?: FilterExpression<FIELDS>;\n}\n\n/** The option every group builder takes. */\nexport interface AggregationGroupScopeOptions {\n /**\n * What the field is relative to when the query expands elements; the\n * innermost element when absent. `ROOT` needs a field input. Wow 9.9 and\n * later.\n */\n scope?: AggregationGroupScope;\n}\n\n/** The options of {@link aggregation.terms}. */\nexport interface TermsAggregationOptions extends AggregationGroupScopeOptions {\n /** The key rows without a value are grouped under; must not be blank. */\n missingKey?: string;\n}\n\n/** The options of {@link aggregation.histogram}. */\nexport interface HistogramAggregationOptions extends AggregationGroupScopeOptions {\n /** The width of each bucket: finite and greater than 0. */\n interval: number;\n}\n\n/** The options of {@link aggregation.dateHistogram}. */\nexport interface DateHistogramAggregationOptions extends AggregationGroupScopeOptions {\n /** The calendar unit of each bucket. */\n unit: AggregationDateUnit;\n /** The zone the buckets are cut in, an IANA id. Defaults to `UTC`. */\n timeZone?: string;\n /**\n * Whether the server fills in the empty buckets of the range. Only when\n * this is the only group.\n */\n dense?: boolean;\n}\n\n/** The options of {@link aggregation.datePart}. */\nexport interface DatePartAggregationOptions extends AggregationGroupScopeOptions {\n /** The calendar part each row is grouped by. */\n part: AggregationDatePart;\n /** The zone the part is read in, an IANA id. Defaults to `UTC`. */\n timeZone?: string;\n /**\n * Whether the server returns every key of the part's domain, the empty\n * ones filled in. Only when this is the only group.\n */\n dense?: boolean;\n}\n\n/** The options of {@link aggregation.first} and {@link aggregation.last}. */\nexport interface EdgeAggregationOptions<\n FIELDS extends string = string,\n> extends AggregationMetricOptions<FIELDS> {\n /**\n * The single-valued, sortable field that orders the records. Defaults to\n * the model's event time, `analysis.firstLastOrderBy` in the descriptor.\n */\n orderBy?: FIELDS;\n}\n\n/** The options of {@link aggregation.percentile}. */\nexport interface PercentileAggregationOptions<\n FIELDS extends string = string,\n> extends AggregationMetricOptions<FIELDS> {\n /** Which percentile: finite and within (0, 100). */\n percentile: number;\n}\n\n/**\n * The sizes Wow's own `AggregationQuery` enforces by throwing.\n *\n * A query that breaks one of them is refused by the server, which says what\n * was wrong but not which metric or group said it. Checking here keeps the\n * complaint next to the call that built the query.\n */\nexport const AGGREGATION_LIMITS = Object.freeze({\n /** Rows returned when a query names no limit of its own. */\n DEFAULT_LIMIT: 100,\n /** The largest `limit`. */\n MAX_LIMIT: 10_000,\n /** The most `elements`. */\n MAX_ELEMENTS: 5,\n /** The most `groupBy` entries. */\n MAX_GROUPS: 32,\n /** The most `metrics`. */\n MAX_METRICS: 64,\n /** The most `sort` fields, including those Wow appends for the groups. */\n MAX_SORT_FIELDS: 32,\n /** The deepest expression tree. */\n MAX_EXPRESSION_DEPTH: 8,\n /** The most expression nodes in the whole query. */\n MAX_EXPRESSION_NODES: 256,\n /** The most windows in the whole query. */\n MAX_WINDOWS: 8,\n});\n"],"mappings":";AAsBA,IAAYA,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,QAAA,SAEA,EAAAC,YAAA,aAEA,EAAAC,iBAAA,kBAKA,EAAAC,YAAA,a;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,UAAA,WAEA,EAAAC,OAAA,Q;AACF,EAAA,CAAA,CAAA,GAOYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,QAAA,SAKA,EAAAC,UAAA,WAEA,EAAAC,MAAA,OAKA,EAAAC,iBAAA,kBAKA,EAAAC,aAAA,cAKA,EAAAC,UAAA,WAKA,EAAAC,QAAA,SAKA,EAAAC,OAAA,Q;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,QAAA,SAEA,EAAAC,WAAA,YAEA,EAAAC,SAAA,UAKA,EAAAC,YAAA,a;AACF,EAAA,CAAA,CAAA,GAOYC,IAAL,yBAAA,GAAA;C,OACL,EAAAC,SAAA,UACA,EAAAC,SAAA,UACA,EAAAC,OAAA,QACA,EAAAC,MAAA,O;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,MAAA,OAEA,EAAAC,WAAA,YAEA,EAAAC,WAAA,YAEA,EAAAC,SAAA,U;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;C,OACL,EAAAC,OAAA,QACA,EAAAC,UAAA,WACA,EAAAC,QAAA,SACA,EAAAC,OAAA,QACA,EAAAV,MAAA,OACA,EAAAD,OAAA,QACA,EAAAD,SAAA,UACA,EAAAD,SAAA,U;AACF,EAAA,CAAA,CAAA,GAOYc,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,cAAA,eAKA,EAAAC,eAAA,gBAEA,EAAAC,cAAA,eAEA,EAAAC,gBAAA,iB;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,MAAA,OAEA,EAAAC,MAAA,OAEA,EAAAC,MAAA,OAEA,EAAAC,MAAA,OAEA,EAAAC,SAAA,UAEA,EAAAC,WAAA,Y;AACF,EAAA,CAAA,CAAA,GA0SYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,aAAA,cAEA,EAAA/B,WAAA,YAEA,EAAAC,SAAA,UAEA,EAAA+B,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,EAAAb,MAAA,OACA,EAAAC,MAAA,O;AACF,EAAA,CAAA,CAAA,GA2EYa,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,YAAA,aAEA,EAAAC,UAAA,WAEA,EAAAC,KAAA,MAKA,EAAAC,UAAA,WAEA,EAAAC,MAAA,OAEA,EAAAC,KAAA,M;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,KAAA,MAEA,EAAAC,KAAA,MAEA,EAAAC,KAAA,MAEA,EAAAC,MAAA,OAEA,EAAAC,KAAA,MAEA,EAAAC,MAAA,O;AACF,EAAA,CAAA,CAAA,GA4KaC,IAAqB,OAAO,OAAO;CAE9C,eAAe;CAEf,WAAW;CAEX,cAAc;CAEd,YAAY;CAEZ,aAAa;CAEb,iBAAiB;CAEjB,sBAAsB;CAEtB,sBAAsB;CAEtB,aAAa;AACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.es.js","names":["AggregationExpressionType","\"FIELD\"","\"CONSTANT\"","\"BINARY\"","\"DATE_DIFF\"","DateDiffUnit","\"SECOND\"","\"MINUTE\"","\"HOUR\"","\"DAY\"","AggregationExpressionOperator","\"ADD\"","\"SUBTRACT\"","\"MULTIPLY\"","\"DIVIDE\"","ComparisonOperator","\"EQ\"","\"NE\"","\"GT\"","\"GTE\"","\"LT\"","\"LTE\"","AGGREGATION_LIMITS"],"sources":["../../../src/dsl/aggregation/types.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ElementFilterExpression,\n FilterExpression,\n QueryField,\n ExpressionFilter,\n} from '../filter/index.js';\nimport type { FieldSort } from '../sort.js';\nimport type { AggregationGroup } from './groups.js';\nimport type { HavingExpression } from './having.js';\nimport type { AggregationMetric } from './metrics.js';\n\n/** The kind of an {@link AggregationExpression} node, sent as its `type`. */\nexport enum AggregationExpressionType {\n /** The value of a field; {@link aggregation.field}. */\n FIELD = 'field',\n /** A number; {@link aggregation.constant}. */\n CONSTANT = 'constant',\n /** Two operands and an {@link AggregationExpressionOperator}. */\n BINARY = 'binary',\n /**\n * The time elapsed between two time fields; {@link aggregation.dateDiff}.\n * Wow 9.2 and later.\n */\n DATE_DIFF = 'date-diff',\n}\n\n/**\n * The unit a `DATE_DIFF` measures elapsed time in. Each has a fixed length:\n * a `DAY` is exactly 24 hours, and months and years, whose length depends on\n * a calendar and a time zone, are not offered.\n */\nexport enum DateDiffUnit {\n SECOND = 'second',\n MINUTE = 'minute',\n HOUR = 'hour',\n DAY = 'day',\n}\n\n/**\n * The arithmetic of a `BINARY` node, in an {@link AggregationExpression} or a\n * {@link DerivedExpression}.\n */\nexport enum AggregationExpressionOperator {\n /** `left + right` */\n ADD = 'add',\n /** `left - right` */\n SUBTRACT = 'subtract',\n /** `left * right` */\n MULTIPLY = 'multiply',\n /** `left / right` */\n DIVIDE = 'divide',\n}\n\n/**\n * An array field whose elements the query aggregates over instead of the\n * root documents; build it with {@link aggregation.element}. A query takes at\n * most `AGGREGATION_LIMITS.MAX_ELEMENTS` of them.\n */\nexport interface AggregationElement {\n /** The array field, a query field path. */\n path: QueryField;\n /**\n * Keeps only the elements that match; no root filters and no search, but\n * an `EXPRESSION` filter may compare an element's computed value.\n */\n filter?: ElementFilterExpression | ExpressionFilter;\n}\n\n/** The value of a field, as an operand; {@link aggregation.field}. */\nexport interface FieldAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.FIELD;\n /** The field, a query field path. */\n field: QueryField<FIELDS>;\n}\n\n/** A number, as an operand; {@link aggregation.constant}. */\nexport interface ConstantAggregationExpression {\n type: AggregationExpressionType.CONSTANT;\n /** A finite number. */\n value: number;\n}\n\n/**\n * `left operator right`; {@link aggregation.add}, {@link aggregation.subtract},\n * {@link aggregation.multiply}, {@link aggregation.divide}.\n */\nexport interface BinaryAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.BINARY;\n /** The arithmetic. */\n operator: AggregationExpressionOperator;\n /** The left operand. */\n left: AggregationExpression<FIELDS>;\n /** The right operand. */\n right: AggregationExpression<FIELDS>;\n}\n\n/**\n * The time from the instant in `from` to the instant in `to`, `to − from`,\n * in `unit`, as a signed decimal: negative when `to` is earlier, and no\n * value when either is absent. Both are single-valued time fields (their\n * `aggregate.groups` list `DATE_HISTOGRAM`), each read in its own encoding;\n * {@link aggregation.dateDiff}. Wow 9.2 and later.\n */\nexport interface DateDiffAggregationExpression<FIELDS extends string = string> {\n type: AggregationExpressionType.DATE_DIFF;\n /** The earlier instant, when the difference is positive. */\n from: QueryField<FIELDS>;\n /** The later instant, when the difference is positive. */\n to: QueryField<FIELDS>;\n /** The unit the difference is measured in. */\n unit: DateDiffUnit;\n}\n\n/**\n * Per-row arithmetic over fields, time differences and numbers, which a\n * metric aggregates, a TERMS or HISTOGRAM group groups by, and an\n * `EXPRESSION` filter compares. A tree at most\n * `AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH` deep and `MAX_EXPRESSION_NODES`\n * large, counted over a query's metrics together and over each group or\n * filter on its own.\n */\nexport type AggregationExpression<FIELDS extends string = string> =\n | FieldAggregationExpression<FIELDS>\n | ConstantAggregationExpression\n | BinaryAggregationExpression<FIELDS>\n | DateDiffAggregationExpression<FIELDS>;\n\n/** The comparison of a `CONDITION` in a {@link HavingExpression}. */\nexport enum ComparisonOperator {\n /** `=` */\n EQ = 'eq',\n /** `≠` */\n NE = 'ne',\n /** `>` */\n GT = 'gt',\n /** `≥` */\n GTE = 'gte',\n /** `<` */\n LT = 'lt',\n /** `≤` */\n LTE = 'lte',\n}\n\n/**\n * An aggregation request: which documents, grouped how, computing which\n * metrics. `QueryModelClient.aggregate` sends it, and each\n * result row holds the groups' and metrics' columns by alias. Assemble it\n * with {@link aggregation.query}, which checks the rules Wow enforces across\n * its parts before anything is sent.\n *\n * Wow 8.11 has no aggregation endpoint; Wow 8.12 added it with `COUNT` and\n * `NUMERIC` metrics, and Wow 9.0 added `ANY`. `having`, the `DISTINCT_COUNT`,\n * `PERCENTILE` and `DERIVED` metrics, metric filters, `missingKey` and `dense`\n * need Wow 9.1.\n *\n * @template ROOT_FIELDS - The fields `filter` may name\n * @template AGGREGATION_FIELDS - The fields groups and metrics may name\n */\nexport interface AggregationQuery<\n ROOT_FIELDS extends string = string,\n AGGREGATION_FIELDS extends string = ROOT_FIELDS,\n> {\n /** Which documents are aggregated; all of them when absent. */\n filter?: FilterExpression<ROOT_FIELDS>;\n /** Array fields to aggregate the elements of, instead of the documents. */\n elements?: AggregationElement[];\n /** The dimensions of the result; one row in total when absent or empty. */\n groupBy?: AggregationGroup<AGGREGATION_FIELDS>[];\n /** The columns computed for each group. */\n metrics: [\n AggregationMetric<AGGREGATION_FIELDS>,\n ...AggregationMetric<AGGREGATION_FIELDS>[],\n ];\n /**\n * The order of the rows, by group or metric alias; needs a `groupBy`. Wow\n * then sorts by each remaining group ascending.\n */\n sort?: FieldSort[];\n /**\n * The most rows returned, 1 to `AGGREGATION_LIMITS.MAX_LIMIT`; the\n * server returns `DEFAULT_LIMIT` (100) when absent.\n */\n limit?: number;\n /**\n * Keeps only the grouped rows whose metrics match, before `sort` and\n * `limit`; built with {@link aggregation.having}. Needs a `groupBy`.\n */\n having?: HavingExpression;\n}\n\n/**\n * The sizes Wow's own `AggregationQuery` enforces by throwing.\n *\n * A query that breaks one of them is refused by the server, which says what\n * was wrong but not which metric or group said it. Checking here keeps the\n * complaint next to the call that built the query.\n */\nexport const AGGREGATION_LIMITS = Object.freeze({\n /** Rows returned when a query names no limit of its own. */\n DEFAULT_LIMIT: 100,\n /** The largest `limit`. */\n MAX_LIMIT: 10_000,\n /** The most `elements`. */\n MAX_ELEMENTS: 5,\n /** The most `groupBy` entries. */\n MAX_GROUPS: 32,\n /** The most `metrics`. */\n MAX_METRICS: 64,\n /** The most `sort` fields, including those Wow appends for the groups. */\n MAX_SORT_FIELDS: 32,\n /** The deepest expression tree. */\n MAX_EXPRESSION_DEPTH: 8,\n /** The most expression nodes in the whole query. */\n MAX_EXPRESSION_NODES: 256,\n /** The most windows in the whole query. */\n MAX_WINDOWS: 8,\n});\n"],"mappings":";AAyBA,IAAYA,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,QAAA,SAEA,EAAAC,WAAA,YAEA,EAAAC,SAAA,UAKA,EAAAC,YAAA,a;AACF,EAAA,CAAA,CAAA,GAOYC,IAAL,yBAAA,GAAA;C,OACL,EAAAC,SAAA,UACA,EAAAC,SAAA,UACA,EAAAC,OAAA,QACA,EAAAC,MAAA,O;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,MAAA,OAEA,EAAAC,WAAA,YAEA,EAAAC,WAAA,YAEA,EAAAC,SAAA,U;AACF,EAAA,CAAA,CAAA,GA6EYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,KAAA,MAEA,EAAAC,KAAA,MAEA,EAAAC,KAAA,MAEA,EAAAC,MAAA,OAEA,EAAAC,KAAA,MAEA,EAAAC,MAAA,O;AACF,EAAA,CAAA,CAAA,GAwDaC,IAAqB,OAAO,OAAO;CAE9C,eAAe;CAEf,WAAW;CAEX,cAAc;CAEd,YAAY;CAEZ,aAAa;CAEb,iBAAiB;CAEjB,sBAAsB;CAEtB,sBAAsB;CAEtB,aAAa;AACf,CAAC"}
|
package/dist/dsl/cursorQuery.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./queryFilter.cjs");var t=2147483646,n=32;function r({filter:n,projection:r={},sort:i=[],size:a,cursor:o=null}={}){if(a!==void 0&&(!Number.isInteger(a)||a<1||a>2147483646))throw TypeError(`size must be between 1 and ${t}.`);if(i.length>32)throw TypeError(`sort must contain at most 32 fields.`);let s=i.map(e=>e.field);if(new Set(s).size!==s.length)throw TypeError(`Cursor sort fields must be unique.`);return{filter:e.queryFilter(n),projection:r,sort:i,size:a,cursor:o}}exports.MAX_CURSOR_SIZE=t,exports.MAX_CURSOR_SORT_FIELDS=n,exports.cursorQuery=r;
|
|
2
2
|
//# sourceMappingURL=cursorQuery.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursorQuery.cjs","names":["
|
|
1
|
+
{"version":3,"file":"cursorQuery.cjs","names":["queryFilter","require_queryFilter","MAX_CURSOR_SIZE","MAX_CURSOR_SORT_FIELDS","cursorQuery","size","sort","fields","entry","filter"],"sources":["../../src/dsl/cursorQuery.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 { FilterExpression } from './filter/index.js';\nimport { queryFilter } from './queryFilter.js';\nimport type { Projection } from './projection.js';\nimport type { FieldSort } from './sort.js';\n\n/**\n * The largest page size the cursor model admits (`CursorQuery` in Wow).\n * Over HTTP the server enforces a smaller, configurable page limit — 100 by\n * default — and answers a larger size with a 400.\n */\nexport const MAX_CURSOR_SIZE = 2_147_483_646;\n/** The most sort fields a cursor query may name. */\nexport const MAX_CURSOR_SORT_FIELDS = 32;\n\n/**\n * The body of a forward-only cursor query, which `QueryModelClient.cursor`\n * sends; build it with {@link cursorQuery}. Unlike a paged query it returns\n * no total, and each page starts where the one before ended.\n */\nexport interface CursorQuery<FIELDS extends string = string> {\n /** What to match. */\n filter: FilterExpression<FIELDS>;\n /** Which fields to return; all of them when absent. */\n projection?: Projection<FIELDS>;\n /**\n * The order of the rows. The server appends a unique field, so each field\n * may appear once.\n */\n sort?: FieldSort<FIELDS>[];\n /**\n * The rows of one page. Absent, the server's default list size, at most\n * its page size: the descriptor's `limits.defaultListSize` and\n * `limits.maxPageSize` (100 and 100 unless the server configures others).\n */\n size?: number;\n /**\n * Where the page starts: `null` or absent for the first page, then the\n * `nextCursor` of the page before, with the same filter and sort.\n */\n cursor?: string | null;\n}\n\n/**\n * What {@link cursorQuery} takes: a cursor query whose `filter` may be\n * absent.\n */\nexport type CursorQueryOptions<FIELDS extends string = string> = Omit<\n CursorQuery<FIELDS>,\n 'filter'\n> & {\n /** What to match. Defaults to `filter.matchAll()`. */\n filter?: FilterExpression<FIELDS>;\n};\n\n/** One page of a cursor query. */\nexport interface CursorPage<T> {\n /** The rows of this page. */\n list: T[];\n /** The `cursor` of the next page, or `null` after the last page. */\n nextCursor: string | null;\n}\n\n/**\n * Builds the body of a cursor query, with the defaults filled in: every\n * record, all fields, no sort, from the start. A `size` is sent only when\n * given; absent, the server pages by its default list size.\n *\n * @throws TypeError when `filter` is `null`, `size` is not an integer from 1 to\n * {@link MAX_CURSOR_SIZE}, or `sort` names more than\n * {@link MAX_CURSOR_SORT_FIELDS} fields or a field twice.\n *\n * @example\n * ```typescript\n * const first = await snapshots.cursor(\n * cursorQuery({ filter: filter.eq('state.status', 'ACTIVE'), size: 50 }),\n * );\n * if (first.nextCursor !== null) {\n * await snapshots.cursor(\n * cursorQuery({\n * filter: filter.eq('state.status', 'ACTIVE'),\n * size: 50,\n * cursor: first.nextCursor,\n * }),\n * );\n * }\n * ```\n */\nexport function cursorQuery<FIELDS extends string = string>({\n filter,\n projection = {},\n sort = [],\n size,\n cursor = null,\n}: CursorQueryOptions<FIELDS> = {}): CursorQuery<FIELDS> {\n if (\n size !== undefined &&\n (!Number.isInteger(size) || size < 1 || size > MAX_CURSOR_SIZE)\n ) {\n throw new TypeError(`size must be between 1 and ${MAX_CURSOR_SIZE}.`);\n }\n if (sort.length > MAX_CURSOR_SORT_FIELDS) {\n throw new TypeError(\n `sort must contain at most ${MAX_CURSOR_SORT_FIELDS} fields.`,\n );\n }\n // A cursor is a position in one total order, so the gateway appends a unique\n // field and then refuses a repeated one: two directions for the same field\n // would leave the position ambiguous and a page could repeat or skip rows.\n const fields = sort.map(entry => entry.field);\n if (new Set(fields).size !== fields.length) {\n throw new TypeError('Cursor sort fields must be unique.');\n }\n return { filter: queryFilter(filter), projection, sort, size, cursor };\n}\n"],"mappings":"A,qCAuBA,IAAaE,EAAkB,WAElBC,EAAyB,GA2EtC,SAAgBC,EAA4C,CAC1D,SACA,aAAa,CAAC,EACd,OAAO,CAAC,EACR,OACA,SAAS,MACqB,CAAC,EAAwB,CACvD,GACEC,IAAS,IAAA,KACR,CAAC,OAAO,UAAUA,CAAI,GAAKA,EAAO,GAAKA,EAAA,YAExC,MAAU,UAAU,8BAA8BH,EAAgB,EAAE,EAEtE,GAAII,EAAK,OAAA,GACP,MAAU,UACR,sCACF,EAKF,IAAMC,EAASD,EAAK,IAAI,GAASE,EAAM,KAAK,EAC5C,GAAI,IAAI,IAAID,CAAM,CAAC,CAAC,OAASA,EAAO,OAClC,MAAU,UAAU,oCAAoC,EAE1D,MAAO,CAAE,OAAQP,EAAAA,YAAYS,CAAM,EAAG,aAAY,OAAM,OAAM,QAAO,CACvE,C"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { FilterExpression } from './filter/index.cjs';
|
|
2
2
|
import { Projection } from './projection.cjs';
|
|
3
3
|
import { FieldSort } from './sort.cjs';
|
|
4
|
-
/** The page size `cursorQuery()` uses when none is given. */
|
|
5
|
-
export declare const DEFAULT_CURSOR_SIZE = 10;
|
|
6
4
|
/**
|
|
7
5
|
* The largest page size the cursor model admits (`CursorQuery` in Wow).
|
|
8
6
|
* Over HTTP the server enforces a smaller, configurable page limit — 100 by
|
|
@@ -26,7 +24,11 @@ export interface CursorQuery<FIELDS extends string = string> {
|
|
|
26
24
|
* may appear once.
|
|
27
25
|
*/
|
|
28
26
|
sort?: FieldSort<FIELDS>[];
|
|
29
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* The rows of one page. Absent, the server's default list size, at most
|
|
29
|
+
* its page size: the descriptor's `limits.defaultListSize` and
|
|
30
|
+
* `limits.maxPageSize` (100 and 100 unless the server configures others).
|
|
31
|
+
*/
|
|
30
32
|
size?: number;
|
|
31
33
|
/**
|
|
32
34
|
* Where the page starts: `null` or absent for the first page, then the
|
|
@@ -34,6 +36,14 @@ export interface CursorQuery<FIELDS extends string = string> {
|
|
|
34
36
|
*/
|
|
35
37
|
cursor?: string | null;
|
|
36
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* What {@link cursorQuery} takes: a cursor query whose `filter` may be
|
|
41
|
+
* absent.
|
|
42
|
+
*/
|
|
43
|
+
export type CursorQueryOptions<FIELDS extends string = string> = Omit<CursorQuery<FIELDS>, 'filter'> & {
|
|
44
|
+
/** What to match. Defaults to `filter.matchAll()`. */
|
|
45
|
+
filter?: FilterExpression<FIELDS>;
|
|
46
|
+
};
|
|
37
47
|
/** One page of a cursor query. */
|
|
38
48
|
export interface CursorPage<T> {
|
|
39
49
|
/** The rows of this page. */
|
|
@@ -42,10 +52,11 @@ export interface CursorPage<T> {
|
|
|
42
52
|
nextCursor: string | null;
|
|
43
53
|
}
|
|
44
54
|
/**
|
|
45
|
-
* Builds the body of a cursor query, with the defaults filled in:
|
|
46
|
-
*
|
|
55
|
+
* Builds the body of a cursor query, with the defaults filled in: every
|
|
56
|
+
* record, all fields, no sort, from the start. A `size` is sent only when
|
|
57
|
+
* given; absent, the server pages by its default list size.
|
|
47
58
|
*
|
|
48
|
-
* @throws TypeError when `size` is not an integer from 1 to
|
|
59
|
+
* @throws TypeError when `filter` is `null`, `size` is not an integer from 1 to
|
|
49
60
|
* {@link MAX_CURSOR_SIZE}, or `sort` names more than
|
|
50
61
|
* {@link MAX_CURSOR_SORT_FIELDS} fields or a field twice.
|
|
51
62
|
*
|
|
@@ -65,4 +76,4 @@ export interface CursorPage<T> {
|
|
|
65
76
|
* }
|
|
66
77
|
* ```
|
|
67
78
|
*/
|
|
68
|
-
export declare function cursorQuery<FIELDS extends string = string>({ filter, projection, sort, size, cursor, }
|
|
79
|
+
export declare function cursorQuery<FIELDS extends string = string>({ filter, projection, sort, size, cursor, }?: CursorQueryOptions<FIELDS>): CursorQuery<FIELDS>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { FilterExpression } from './filter/index.js';
|
|
2
2
|
import { Projection } from './projection.js';
|
|
3
3
|
import { FieldSort } from './sort.js';
|
|
4
|
-
/** The page size `cursorQuery()` uses when none is given. */
|
|
5
|
-
export declare const DEFAULT_CURSOR_SIZE = 10;
|
|
6
4
|
/**
|
|
7
5
|
* The largest page size the cursor model admits (`CursorQuery` in Wow).
|
|
8
6
|
* Over HTTP the server enforces a smaller, configurable page limit — 100 by
|
|
@@ -26,7 +24,11 @@ export interface CursorQuery<FIELDS extends string = string> {
|
|
|
26
24
|
* may appear once.
|
|
27
25
|
*/
|
|
28
26
|
sort?: FieldSort<FIELDS>[];
|
|
29
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* The rows of one page. Absent, the server's default list size, at most
|
|
29
|
+
* its page size: the descriptor's `limits.defaultListSize` and
|
|
30
|
+
* `limits.maxPageSize` (100 and 100 unless the server configures others).
|
|
31
|
+
*/
|
|
30
32
|
size?: number;
|
|
31
33
|
/**
|
|
32
34
|
* Where the page starts: `null` or absent for the first page, then the
|
|
@@ -34,6 +36,14 @@ export interface CursorQuery<FIELDS extends string = string> {
|
|
|
34
36
|
*/
|
|
35
37
|
cursor?: string | null;
|
|
36
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* What {@link cursorQuery} takes: a cursor query whose `filter` may be
|
|
41
|
+
* absent.
|
|
42
|
+
*/
|
|
43
|
+
export type CursorQueryOptions<FIELDS extends string = string> = Omit<CursorQuery<FIELDS>, 'filter'> & {
|
|
44
|
+
/** What to match. Defaults to `filter.matchAll()`. */
|
|
45
|
+
filter?: FilterExpression<FIELDS>;
|
|
46
|
+
};
|
|
37
47
|
/** One page of a cursor query. */
|
|
38
48
|
export interface CursorPage<T> {
|
|
39
49
|
/** The rows of this page. */
|
|
@@ -42,10 +52,11 @@ export interface CursorPage<T> {
|
|
|
42
52
|
nextCursor: string | null;
|
|
43
53
|
}
|
|
44
54
|
/**
|
|
45
|
-
* Builds the body of a cursor query, with the defaults filled in:
|
|
46
|
-
*
|
|
55
|
+
* Builds the body of a cursor query, with the defaults filled in: every
|
|
56
|
+
* record, all fields, no sort, from the start. A `size` is sent only when
|
|
57
|
+
* given; absent, the server pages by its default list size.
|
|
47
58
|
*
|
|
48
|
-
* @throws TypeError when `size` is not an integer from 1 to
|
|
59
|
+
* @throws TypeError when `filter` is `null`, `size` is not an integer from 1 to
|
|
49
60
|
* {@link MAX_CURSOR_SIZE}, or `sort` names more than
|
|
50
61
|
* {@link MAX_CURSOR_SORT_FIELDS} fields or a field twice.
|
|
51
62
|
*
|
|
@@ -65,4 +76,4 @@ export interface CursorPage<T> {
|
|
|
65
76
|
* }
|
|
66
77
|
* ```
|
|
67
78
|
*/
|
|
68
|
-
export declare function cursorQuery<FIELDS extends string = string>({ filter, projection, sort, size, cursor, }
|
|
79
|
+
export declare function cursorQuery<FIELDS extends string = string>({ filter, projection, sort, size, cursor, }?: CursorQueryOptions<FIELDS>): CursorQuery<FIELDS>;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import { queryFilter as e } from "./queryFilter.es.js";
|
|
1
2
|
// src/dsl/cursorQuery.ts
|
|
2
|
-
var
|
|
3
|
-
function r({ filter:
|
|
4
|
-
if (!Number.isInteger(
|
|
5
|
-
if (
|
|
6
|
-
let
|
|
7
|
-
if (new Set(
|
|
3
|
+
var t = 2147483646, n = 32;
|
|
4
|
+
function r({ filter: n, projection: r = {}, sort: i = [], size: a, cursor: o = null } = {}) {
|
|
5
|
+
if (a !== void 0 && (!Number.isInteger(a) || a < 1 || a > 2147483646)) throw TypeError(`size must be between 1 and ${t}.`);
|
|
6
|
+
if (i.length > 32) throw TypeError("sort must contain at most 32 fields.");
|
|
7
|
+
let s = i.map((e) => e.field);
|
|
8
|
+
if (new Set(s).size !== s.length) throw TypeError("Cursor sort fields must be unique.");
|
|
8
9
|
return {
|
|
9
|
-
filter: e,
|
|
10
|
-
projection:
|
|
11
|
-
sort:
|
|
12
|
-
size:
|
|
13
|
-
cursor:
|
|
10
|
+
filter: e(n),
|
|
11
|
+
projection: r,
|
|
12
|
+
sort: i,
|
|
13
|
+
size: a,
|
|
14
|
+
cursor: o
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
|
-
export {
|
|
17
|
+
export { t as MAX_CURSOR_SIZE, n as MAX_CURSOR_SORT_FIELDS, r as cursorQuery };
|
|
17
18
|
|
|
18
19
|
//# sourceMappingURL=cursorQuery.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursorQuery.es.js","names":["
|
|
1
|
+
{"version":3,"file":"cursorQuery.es.js","names":["MAX_CURSOR_SIZE","MAX_CURSOR_SORT_FIELDS","cursorQuery","size","sort","fields","entry","queryFilter","filter"],"sources":["../../src/dsl/cursorQuery.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 { FilterExpression } from './filter/index.js';\nimport { queryFilter } from './queryFilter.js';\nimport type { Projection } from './projection.js';\nimport type { FieldSort } from './sort.js';\n\n/**\n * The largest page size the cursor model admits (`CursorQuery` in Wow).\n * Over HTTP the server enforces a smaller, configurable page limit — 100 by\n * default — and answers a larger size with a 400.\n */\nexport const MAX_CURSOR_SIZE = 2_147_483_646;\n/** The most sort fields a cursor query may name. */\nexport const MAX_CURSOR_SORT_FIELDS = 32;\n\n/**\n * The body of a forward-only cursor query, which `QueryModelClient.cursor`\n * sends; build it with {@link cursorQuery}. Unlike a paged query it returns\n * no total, and each page starts where the one before ended.\n */\nexport interface CursorQuery<FIELDS extends string = string> {\n /** What to match. */\n filter: FilterExpression<FIELDS>;\n /** Which fields to return; all of them when absent. */\n projection?: Projection<FIELDS>;\n /**\n * The order of the rows. The server appends a unique field, so each field\n * may appear once.\n */\n sort?: FieldSort<FIELDS>[];\n /**\n * The rows of one page. Absent, the server's default list size, at most\n * its page size: the descriptor's `limits.defaultListSize` and\n * `limits.maxPageSize` (100 and 100 unless the server configures others).\n */\n size?: number;\n /**\n * Where the page starts: `null` or absent for the first page, then the\n * `nextCursor` of the page before, with the same filter and sort.\n */\n cursor?: string | null;\n}\n\n/**\n * What {@link cursorQuery} takes: a cursor query whose `filter` may be\n * absent.\n */\nexport type CursorQueryOptions<FIELDS extends string = string> = Omit<\n CursorQuery<FIELDS>,\n 'filter'\n> & {\n /** What to match. Defaults to `filter.matchAll()`. */\n filter?: FilterExpression<FIELDS>;\n};\n\n/** One page of a cursor query. */\nexport interface CursorPage<T> {\n /** The rows of this page. */\n list: T[];\n /** The `cursor` of the next page, or `null` after the last page. */\n nextCursor: string | null;\n}\n\n/**\n * Builds the body of a cursor query, with the defaults filled in: every\n * record, all fields, no sort, from the start. A `size` is sent only when\n * given; absent, the server pages by its default list size.\n *\n * @throws TypeError when `filter` is `null`, `size` is not an integer from 1 to\n * {@link MAX_CURSOR_SIZE}, or `sort` names more than\n * {@link MAX_CURSOR_SORT_FIELDS} fields or a field twice.\n *\n * @example\n * ```typescript\n * const first = await snapshots.cursor(\n * cursorQuery({ filter: filter.eq('state.status', 'ACTIVE'), size: 50 }),\n * );\n * if (first.nextCursor !== null) {\n * await snapshots.cursor(\n * cursorQuery({\n * filter: filter.eq('state.status', 'ACTIVE'),\n * size: 50,\n * cursor: first.nextCursor,\n * }),\n * );\n * }\n * ```\n */\nexport function cursorQuery<FIELDS extends string = string>({\n filter,\n projection = {},\n sort = [],\n size,\n cursor = null,\n}: CursorQueryOptions<FIELDS> = {}): CursorQuery<FIELDS> {\n if (\n size !== undefined &&\n (!Number.isInteger(size) || size < 1 || size > MAX_CURSOR_SIZE)\n ) {\n throw new TypeError(`size must be between 1 and ${MAX_CURSOR_SIZE}.`);\n }\n if (sort.length > MAX_CURSOR_SORT_FIELDS) {\n throw new TypeError(\n `sort must contain at most ${MAX_CURSOR_SORT_FIELDS} fields.`,\n );\n }\n // A cursor is a position in one total order, so the gateway appends a unique\n // field and then refuses a repeated one: two directions for the same field\n // would leave the position ambiguous and a page could repeat or skip rows.\n const fields = sort.map(entry => entry.field);\n if (new Set(fields).size !== fields.length) {\n throw new TypeError('Cursor sort fields must be unique.');\n }\n return { filter: queryFilter(filter), projection, sort, size, cursor };\n}\n"],"mappings":";;AAuBA,IAAaA,IAAkB,YAElBC,IAAyB;AA2EtC,SAAgBC,EAA4C,EAC1D,WACA,gBAAa,CAAC,GACd,UAAO,CAAC,GACR,SACA,YAAS,SACqB,CAAC,GAAwB;CACvD,IACEC,MAAS,KAAA,MACR,CAAC,OAAO,UAAUA,CAAI,KAAKA,IAAO,KAAKA,IAAA,aAExC,MAAU,UAAU,8BAA8BH,EAAgB,EAAE;CAEtE,IAAII,EAAK,SAAA,IACP,MAAU,UACR,sCACF;CAKF,IAAMC,IAASD,EAAK,KAAI,MAASE,EAAM,KAAK;CAC5C,IAAI,IAAI,IAAID,CAAM,CAAC,CAAC,SAASA,EAAO,QAClC,MAAU,UAAU,oCAAoC;CAE1D,OAAO;EAAE,QAAQE,EAAYC,CAAM;EAAG;EAAY;EAAM;EAAM;CAAO;AACvE"}
|
package/dist/dsl/descriptor.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=Object.freeze({SNAPSHOT:`snapshot`,EVENT_STREAM:`events`,DATASET:`dataset`}),t=
|
|
1
|
+
var e=Object.freeze({SNAPSHOT:`snapshot`,EVENT_STREAM:`events`,DATASET:`dataset`}),t=function(e){return e.LIST=`list`,e.PAGED=`paged`,e.CURSOR=`cursor`,e}({}),n=Object.freeze({CURSOR_UNIQUE_SORT:`cursor-unique-sort`,COUNT_REQUIRES_FILTER:`count-requires-filter`,STARTS_WITH_REQUIRES_PREFIX:`starts-with-requires-prefix`,PARALLEL_ARRAY_SORT:`parallel-array-sort`,NULL_OR_EMPTY_AS_MISSING:`null-or-empty-as-missing`,ARRAY_EQUALITY:`array-equality`,AGGREGATE_REQUIRED:`aggregate-required`});exports.PagingMode=t,exports.QueryConstraintTypes=n,exports.QueryModels=e;
|
|
2
2
|
//# sourceMappingURL=descriptor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor.cjs","names":["QueryModels","QueryValueTypes","QueryValueKind","\"UNKNOWN\"","\"NULL\"","\"SCALAR\"","\"OBJECT\"","\"ARRAY\"","\"UNION\"","PagingMode","\"LIST\"","\"PAGED\"","\"CURSOR\"","QueryFieldRoles","QueryConstraintTypes","QuerySemanticTypes","SensitivityLevel","\"DISPLAY\"","\"CONFIDENTIAL\""],"sources":["../../src/dsl/descriptor.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\n// The capability descriptor `GET {aggregate}/{snapshot|event}/schema`\n// answers with: `wow.api.query.QueryModelDescriptor` of Wow 9.2, mirrored\n// from `wow-api/src/main/kotlin/me/ahoo/wow/api/query/descriptor/`.\n//\n// Kotlin leaves a null out of the JSON of every descriptor class annotated\n// `@JsonInclude(NON_NULL)`, so those properties are optional here; the\n// limits are not annotated and send `null`. A set the OpenAPI document\n// describes as a plain string is open: a known union plus `string & {}`.\n\nimport type {\n AggregationDatePart,\n AggregationDateUnit,\n DateDiffUnit,\n AggregationFunction,\n AggregationGroupType,\n AggregationMetricType,\n WindowFunction,\n} from './aggregation/types.js';\nimport type { DeletionState } from './deletionState.js';\nimport type { FilterOperator, SearchMode, TimeUnit } from './filter/index.js';\n\n/**\n * A query model's capability descriptor and its version, the `ETag` of\n * `GET …/query`; `notModified` when the version given is still current.\n */\nexport type DescriptorResult =\n | {\n readonly notModified: false;\n readonly version?: string;\n readonly descriptor: QueryModelDescriptor;\n }\n | { readonly notModified: true; readonly version: string };\n\n/**\n * The query models Wow names in a descriptor's `model`. The set is open: a\n * server may register a model of its own, so a descriptor's `model` is a\n * {@link QueryModel}.\n */\nexport const QueryModels = Object.freeze({\n /** The snapshot query model: `{aggregate}/snapshot/*`. */\n SNAPSHOT: 'snapshot',\n /** The event stream query model: `{aggregate}/event/*`. */\n EVENT_STREAM: 'events',\n /** A declared dataset, such as a ClickHouse wide table: `dataset/{context}/{dataset}/*`. */\n DATASET: 'dataset',\n} as const);\n\n/** A query model's name: one of {@link QueryModels}, or one a server added. */\nexport type QueryModel =\n (typeof QueryModels)[keyof typeof QueryModels] | (string & {});\n\n/**\n * The value types Wow names in a field's `types`. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryValueTypes = Object.freeze({\n /** A JSON string. */\n STRING: 'string',\n /** A whole number. */\n INTEGER: 'integer',\n /** A number with a fraction. */\n DECIMAL: 'decimal',\n /** `true` or `false`. */\n BOOLEAN: 'boolean',\n /** A JSON object. */\n OBJECT: 'object',\n} as const);\n\n/** A field's value type: one of {@link QueryValueTypes}, or one a server added. */\nexport type QueryValueType =\n (typeof QueryValueTypes)[keyof typeof QueryValueTypes] | (string & {});\n\n/** The structural shape of a field's value, sent as its `kind`. */\nexport enum QueryValueKind {\n /** Wow could not tell. */\n UNKNOWN = 'unknown',\n /** Always `null`. */\n NULL = 'null',\n /** A single string, number or boolean. */\n SCALAR = 'scalar',\n /** An object. */\n OBJECT = 'object',\n /** An array. */\n ARRAY = 'array',\n /** One of several of the above. */\n UNION = 'union',\n}\n\n/** The ways a model can be read page by page, listed in `record.paging`. */\nexport enum PagingMode {\n /** `list` and `stream`: the first `limit` rows. */\n LIST = 'list',\n /** `paged`: numbered pages with a total. */\n PAGED = 'paged',\n /** `cursor`: forward-only pages after the last row seen. */\n CURSOR = 'cursor',\n}\n\n/**\n * The system roles Wow names in a field's `role`: the system fields a root\n * operator targets, and the model's times. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryFieldRoles = Object.freeze({\n /** The record's own identity, `record.identity`. */\n IDENTITY: 'identity',\n /** The aggregate id. */\n AGGREGATE_ID: 'aggregate-id',\n /** The tenant id. */\n TENANT_ID: 'tenant-id',\n /** The owner id. */\n OWNER_ID: 'owner-id',\n /** The space id. */\n SPACE_ID: 'space-id',\n /** Whether the aggregate is deleted. */\n DELETED: 'deleted',\n /**\n * When the record's events happened: a snapshot's last event\n * (`eventTime`), an event stream's events (`createTime`). `FIRST` and\n * `LAST` order by it when they name no `orderBy`. Wow 9.2 and later.\n */\n EVENT_TIME: 'event-time',\n /**\n * When a snapshot's aggregate got its first event, i.e. was created\n * (`firstEventTime`). Wow 9.2 and later.\n */\n FIRST_EVENT_TIME: 'first-event-time',\n} as const);\n\n/** A system field's role: one of {@link QueryFieldRoles}, or one a server added. */\nexport type QueryFieldRole =\n (typeof QueryFieldRoles)[keyof typeof QueryFieldRoles] | (string & {});\n\n/**\n * The combination rules Wow names in a descriptor's `constraints`: rules\n * that no single capability shows. The set is open, like {@link QueryModels}.\n */\nexport const QueryConstraintTypes = Object.freeze({\n /**\n * A cursor's sort always ends with the identity field; the server appends\n * it (the constraint's `appended`) when the sort does not.\n */\n CURSOR_UNIQUE_SORT: 'cursor-unique-sort',\n /** A count or paged query must not match every record. */\n COUNT_REQUIRES_FILTER: 'count-requires-filter',\n /** `STARTS_WITH` needs a non-empty, case-sensitive prefix. */\n STARTS_WITH_REQUIRES_PREFIX: 'starts-with-requires-prefix',\n /**\n * A sort names at most one of the constraint's `fields`: they are\n * array-valued and the storage cannot order by two independent arrays.\n * Fields on one array path, one nested in the other, may still combine.\n * A sort that breaks it is refused with `PARALLEL_ARRAY_SORT`.\n */\n PARALLEL_ARRAY_SORT: 'parallel-array-sort',\n /**\n * On the constraint's `fields`, a stored `null` or empty array cannot be\n * told from a missing field: `EXISTS` does not match it, `NOT_EXISTS` and\n * `IS_NULL` do, and `IS_EMPTY` also matches a missing or `null` field. A\n * presence filter on such a field answers \"has a non-empty value\", not\n * \"has the key\"; say so to a user who writes one.\n */\n NULL_OR_EMPTY_AS_MISSING: 'null-or-empty-as-missing',\n /**\n * Model-wide, without `fields`: `EQ` and `NE` take only a scalar operand,\n * because the storage cannot compare a whole array. Match an array\n * field's elements instead (`IN`, `CONTAINS_ALL`, `ELEMENT_MATCH`); an `EQ` or\n * `NE` with an array operand is refused with `ARRAY_EQUALITY`.\n */\n ARRAY_EQUALITY: 'array-equality',\n} as const);\n\n/** A constraint's type: one of {@link QueryConstraintTypes}, or one a server added. */\nexport type QueryConstraintType =\n | (typeof QueryConstraintTypes)[keyof typeof QueryConstraintTypes]\n | (string & {});\n\n/**\n * The semantics Wow names in a field's `semantic.type`, one per member of\n * {@link QuerySemanticType}: read a descriptor's semantic by these rather\n * than by its spelling.\n */\nexport const QuerySemanticTypes = Object.freeze({\n /** A calendar date: {@link TemporalDate}. */\n TEMPORAL_DATE: 'temporal-date',\n /** A number of time units since the epoch: {@link TemporalEpoch}. */\n TEMPORAL_EPOCH: 'temporal-epoch',\n /** A time written as text in a pattern: {@link TemporalFormatted}. */\n TEMPORAL_FORMATTED: 'temporal-formatted',\n /** A fixed-point decimal: {@link NumericDecimal}. */\n DECIMAL: 'decimal',\n /** An amount of money: {@link NumericMoney}. */\n MONEY: 'money',\n /** A length of time: {@link DurationSemantic}. */\n DURATION: 'duration',\n /** The id of an aggregate: {@link ReferenceSemantic}. */\n REFERENCE: 'reference',\n} as const);\n\n/** A field that holds a calendar date. */\nexport interface TemporalDate {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.TEMPORAL_DATE;\n}\n\n/** A field that holds a number of time units since the epoch. */\nexport interface TemporalEpoch {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.TEMPORAL_EPOCH;\n /** The unit the number counts; milliseconds when absent. */\n timeUnit?: TimeUnit;\n}\n\n/** A field that holds a time written as text in a `java.time` pattern. */\nexport interface TemporalFormatted {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.TEMPORAL_FORMATTED;\n /** The `java.time` pattern, such as `yyyy-MM-dd`. */\n pattern: string;\n}\n\n/**\n * A number field meant as a fixed-point decimal with `scale` fraction\n * digits: format and total it at that precision. Declared on the model\n * (`@QueryDecimal`), never inferred. Wow 9.2 and later.\n */\nexport interface NumericDecimal {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.DECIMAL;\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n}\n\n/**\n * A number field meant as an amount of money, in exactly one of a fixed\n * ISO 4217 `currency` or the currency held by the sibling string field\n * `currencyField` (a property of the same object or element). `scale` is\n * always sent: with a fixed currency the server resolves an omitted one to\n * that currency's standard fraction digits (2 for CNY, 0 for JPY).\n * Amounts in different currencies must not be totalled together. Declared\n * on the model (`@QueryMoney`), never inferred. Wow 9.2 and later.\n */\nexport type NumericMoney = {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.MONEY;\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n} & (\n | {\n /** The fixed ISO 4217 currency code, such as `CNY`. */\n currency: string;\n currencyField?: undefined;\n }\n | {\n currency?: undefined;\n /** The sibling property that holds each value's currency code. */\n currencyField: string;\n }\n);\n\n/**\n * A number field that is a length of time counted in `timeUnit`, such as a\n * timeout in seconds: format it as a duration. Declared on the model\n * (`@QueryDuration`), never inferred. Wow 9.2 and later.\n */\nexport interface DurationSemantic {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.DURATION;\n /** The unit the number counts; always sent. */\n timeUnit: TimeUnit;\n}\n\n/**\n * A field whose value is the id of an aggregate, to look it up and link to\n * it: either a fixed aggregate, `contextName` and `aggregateName`, or per\n * record the aggregate the sibling string fields `contextNameField` and\n * `aggregateNameField` name (as in an `AggregateId`). The id is always the\n * aggregate's own. Declared on the model (`@QueryReference`), or inferred\n * for an `AggregateId`. Wow 9.2 and later.\n */\nexport type ReferenceSemantic = {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.REFERENCE;\n} & (\n | {\n /** The referenced aggregate's bounded context. */\n contextName: string;\n /** The referenced aggregate's name. */\n aggregateName: string;\n contextNameField?: undefined;\n aggregateNameField?: undefined;\n }\n | {\n contextName?: undefined;\n aggregateName?: undefined;\n /** The sibling property that holds each value's bounded context. */\n contextNameField: string;\n /** The sibling property that holds each value's aggregate name. */\n aggregateNameField: string;\n }\n);\n\n/**\n * What a field's value means beyond its type, sent as its `semantic`: one\n * of the three temporal kinds, which the relative time filters (`TODAY`,\n * `RECENT_DAYS`, …) and date histograms need; one of the two numeric\n * formats, which say how a number is read and displayed; a duration; or a\n * reference to an aggregate. A field has one; an array field's is its\n * items'.\n *\n * The union grows in minor releases, as the server learns a semantic, and a\n * server newer than this client may send a `type` not listed here. The\n * descriptor is read as JSON, not parsed, so it arrives as it is: keep a\n * `default` branch in a `switch` over `type`, and treat a `type` you do not\n * know as no semantic at all. The union stays closed so that narrowing on\n * `type` still works.\n */\nexport type QuerySemanticType =\n | TemporalDate\n | TemporalEpoch\n | TemporalFormatted\n | NumericDecimal\n | NumericMoney\n | DurationSemantic\n | ReferenceSemantic;\n\n/** One declared value of an enum field, with its description when it has one. */\nexport interface EnumValueDescriptor {\n /** The value as it is stored and filtered by. */\n value: unknown;\n /**\n * What the value means, when the model describes it: set by the `enum`\n * entry of the model's declaration file.\n */\n description?: string;\n}\n\n/**\n * How much Wow protects a sensitive field's raw value, sent as its\n * `sensitivity.level`. Both levels mask the value in every query result;\n * they differ in what a query may do with the raw value.\n */\nexport enum SensitivityLevel {\n /**\n * Masked in results. Filters and paged sorts still compare the raw value,\n * unless the server turned that off; grouping, `ANY`, field metrics,\n * arithmetic references and cursor sorts are refused.\n */\n DISPLAY = 'display',\n /**\n * Masked in results and never compared: no filter, sort, search, grouping\n * or metric may name it.\n */\n CONFIDENTIAL = 'confidential',\n}\n\n/**\n * Why a field is deprecated. The field can still be queried, but new\n * queries and view definitions should avoid it.\n */\nexport interface QueryDeprecation {\n /** Why, or what to use instead; absent when the declaration gave no reason. */\n message?: string;\n}\n\n/** How a sensitive field is protected. */\nexport interface SensitivityDescriptor {\n /** How much its raw value is protected. */\n level: SensitivityLevel;\n /**\n * Whether filters and paged sorts may still compare its raw value: `false`\n * for {@link SensitivityLevel.CONFIDENTIAL}, and for\n * {@link SensitivityLevel.DISPLAY} when the server turned comparison off.\n * A field that is not comparable lists no filter operators, has\n * `sort.paged` `false` and is left out of `record.search`; naming it in a\n * filter, sort or search is refused with `PROTECTED_COMPARISON`.\n */\n comparable: boolean;\n}\n\n/** The filter operators a field admits. */\nexport interface FieldFilterDescriptor {\n /**\n * Each operator admitted on this field when used alone; empty when none,\n * as for a sensitive field that is not comparable.\n */\n operators: FilterOperator[];\n}\n\n/** Where a field may appear in a sort. */\nexport interface FieldSortDescriptor {\n /** In the sort of a list or paged query; never for a field that is not comparable. */\n paged: boolean;\n /** In the sort of a cursor query. */\n cursor: boolean;\n /**\n * Whether an index backs the sort, as the storage says: `false` marks a\n * sort it runs without one, which may be slow on a large model; absent\n * when the storage does not say.\n */\n indexed?: boolean;\n}\n\n/** How a field may be used in an aggregation. */\nexport interface FieldAggregateDescriptor {\n /**\n * The group types it may be grouped by; a time field lists both\n * `DATE_HISTOGRAM` and `DATE_PART`.\n */\n groups: (AggregationGroupType | (string & {}))[];\n /** Whether a terms group on it may set `missingKey`. */\n missingKey: boolean;\n /** The numeric functions (`SUM`, `AVG`, …) it may feed. */\n functions: (AggregationFunction | (string & {}))[];\n /** Whether it may feed a `DISTINCT_COUNT` metric. */\n distinctCount: boolean;\n /** Whether it may feed a `PERCENTILE` metric. */\n percentile: boolean;\n /** Whether it may feed an `ANY` metric. */\n any: boolean;\n /** Whether a `FIRST` or `LAST` metric may read its value. */\n firstLast: boolean;\n /** Whether it may appear in an arithmetic expression. */\n expressionInput: boolean;\n /** Whether a metric's filter may name it. */\n inMetricFilter: boolean;\n}\n\n/** One queryable field, by the logical path a query names it with. */\nexport interface FieldDescriptor {\n /** The logical path, such as `state.items.productId`. */\n path: string;\n /** The system role of a system field; absent on ordinary fields. */\n role?: QueryFieldRole;\n /** The value types it holds. */\n types: QueryValueType[];\n /** The structural shape of its value. */\n kind: QueryValueKind;\n /** Whether it may be `null`. */\n nullable: boolean;\n /** What its value means beyond its type; absent when nothing more. */\n semantic?: QuerySemanticType;\n /** Its declared values; never listed for a protected field. */\n enum?: EnumValueDescriptor[];\n /** Its description, when the model gives one. */\n description?: string;\n /** How it is protected; absent when it is not sensitive. */\n sensitivity?: SensitivityDescriptor;\n /** Whether a projection may select it. */\n project: boolean;\n /** The filter operators it admits. */\n filter: FieldFilterDescriptor;\n /** Where it may be sorted by. */\n sort: FieldSortDescriptor;\n /** How it may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\n /**\n * The element (array field) it lives in, by path; absent at the record\n * level. A filter on it goes inside `ELEMENT_MATCH` on that element.\n */\n scope?: string;\n /**\n * Set when the field is deprecated: still queryable, but new queries\n * should avoid it. An object, so it is truthy even without a message.\n */\n deprecated?: QueryDeprecation;\n /**\n * Other paths a query may name this field by, sorted; empty when none.\n * The server replaces an alias with `path` before it checks and runs a\n * query, so results, projections and errors use `path`, and an alias is\n * never listed as a field of its own. A variant's field lists them\n * relative to the element, like its `path`.\n */\n aliases: string[];\n}\n\n/** An array field whose elements can be filtered or aggregated one by one. */\nexport interface ElementDescriptor {\n /** The array field's logical path. */\n path: string;\n /** Whether `ELEMENT_MATCH` may filter its elements. */\n filter: boolean;\n /** Whether an aggregation may run over its elements. */\n aggregate: boolean;\n /**\n * Full-text search on its fields: a `SEARCH` that names them, relative\n * to the element, inside an `ELEMENT_MATCH` on it. Absent when the\n * storage can search none of them, as on MongoDB.\n */\n search?: SearchDescriptor;\n}\n\n/**\n * The fields under a map's dynamic keys, written with `{key}` in place of\n * the key: any key matches, except those in `excludedKeys`. Each pattern\n * has one entry, resolved as the server resolves a concrete key: a pattern\n * whose values are arrays is one `ARRAY` entry, its items implicit.\n */\nexport interface DynamicFieldDescriptor {\n /** The path pattern, such as `state.attributes.{key}`. */\n pattern: string;\n /** The value types they hold. */\n types: QueryValueType[];\n /** The structural shape of their values. */\n kind: QueryValueKind;\n /** Whether their values may be `null`, as a field's `nullable` says. */\n nullable: boolean;\n /**\n * What their values mean beyond their type, as a field's `semantic`\n * says; absent when nothing more.\n */\n semantic?: QuerySemanticType;\n /** The filter operators they admit. */\n filter: FieldFilterDescriptor;\n /** Where a concrete key may be sorted by. */\n sort: FieldSortDescriptor;\n /** How a concrete key may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\n /**\n * The map's keys that are declared as fields of their own and so are not\n * covered by this pattern; absent when there are none. For\n * `state.attributes.{key}` with `state.attributes.color` declared, it is\n * `['color']`: a filter on `state.attributes.color` takes that field's\n * entry in `fields`, with its own operators, not this pattern's.\n */\n excludedKeys?: string[];\n}\n\n/**\n * Full-text search in one scope: the record's (`record.search`) or an\n * element's (`elements[].search`).\n */\nexport interface SearchDescriptor {\n /**\n * For the record, the modes of a model-wide `SEARCH` (without fields);\n * empty when one of its fields is not comparable, since a search across\n * the model would match that field. For an element, the modes every\n * listed field accepts.\n */\n modes: SearchMode[];\n /**\n * The fields a `SEARCH` may name, by full logical path; never one that is\n * not comparable. For the record, only record-level fields, never one\n * inside an element; for an element, its own fields, which the query\n * writes relative to the element.\n */\n fields: string[];\n}\n\n/** What holds for the model's records as a whole. */\nexport interface RecordDescriptor {\n /** The logical path of the field that identifies a record. */\n identity: string;\n /** The ways the model can be read page by page. */\n paging: PagingMode[];\n /** The deletion scope a query without one gets; absent when the model has none. */\n defaultScope?: DeletionState;\n /**\n * Operators that name no field of their own: the system-field ones, such\n * as `ID` or `TENANT_ID`, and `EXPRESSION`, whose expression names its\n * fields, where the server allows expensive operators.\n */\n rootOperators: FilterOperator[];\n /** Model-wide full-text search; absent when the model offers none. */\n search?: SearchDescriptor;\n}\n\n/** The fixed limits of an aggregation query. */\nexport interface AggregationLimitsDescriptor {\n /** Most groups in `groupBy`. */\n maxGroups: number;\n /** Most metrics. */\n maxMetrics: number;\n /** Most elements an aggregation runs over. */\n maxElements: number;\n /** Largest `limit` on the result rows. */\n maxLimit: number;\n /** Deepest arithmetic expression. */\n maxExpressionDepth: number;\n /** Most nodes in one arithmetic expression. */\n maxExpressionNodes: number;\n /**\n * The most groups an aggregation may read where the server computes part of\n * it (HAVING, a metric sort, dense fill or windows its storage cannot run),\n * beyond which the query fails; `null` or absent is unlimited. Absent from\n * servers before Wow 9.10.\n */\n maxResidualGroups?: number | null;\n}\n\n/**\n * The effective limits of the entry the descriptor was read from: the\n * protocol's and the entry's budget, whichever is smaller. `null` is\n * unlimited.\n */\nexport interface LimitsDescriptor {\n /** Largest `limit` of a list query. */\n maxListSize: number | null;\n /** The `limit` a list query without one gets. */\n defaultListSize: number | null;\n /** Largest page `size` of a paged or cursor query. */\n maxPageSize: number | null;\n /** How far a paged query may reach: page index times size. */\n maxPageWindow: number | null;\n /** Most nodes in one filter. */\n maxFilterNodes: number | null;\n /** Most values in one filter, `IN` lists included. */\n maxFilterValues: number | null;\n /** Most fields in one sort. */\n maxSortFields: number;\n /** The limits of an aggregation query. */\n aggregation: AggregationLimitsDescriptor;\n}\n\n/** The metrics a `having` clause may test. */\nexport interface HavingDescriptor {\n /** The metric types it may name; never `ANY`, `FIRST` or `LAST`. */\n metrics: (AggregationMetricType | (string & {}))[];\n}\n\n/** What an aggregation's result rows may be sorted by. */\nexport interface AnalysisSortDescriptor {\n /** By a group. */\n groups: boolean;\n /** By a metric. */\n metrics: boolean;\n}\n\n/** The aggregation features the model offers. */\nexport interface AnalysisDescriptor {\n /** The metric types it admits. */\n metrics: (AggregationMetricType | (string & {}))[];\n /**\n * The metric types among `metrics` whose results this backend estimates\n * rather than computes exactly, such as `PERCENTILE` on MongoDB, or\n * `DISTINCT_COUNT` and `PERCENTILE` on Elasticsearch; empty when every\n * result is exact. The set is open, like `metrics`: label a result of a\n * listed type as approximate.\n */\n approximate: (AggregationMetricType | (string & {}))[];\n /**\n * Whether computed expressions (arithmetic and `DATE_DIFF`) may feed\n * metrics and TERMS / HISTOGRAM groups, and be compared by an `EXPRESSION`\n * filter. A `DATE_DIFF` operand is any field whose `aggregate.groups`\n * lists `DATE_HISTOGRAM`.\n */\n expressions: boolean;\n /** What `having` may test. */\n having: HavingDescriptor;\n /** What result rows may be sorted by. */\n sort: AnalysisSortDescriptor;\n /**\n * Whether a date histogram or a date part group may fill its empty\n * buckets (`dense`).\n */\n dense: boolean;\n /** The calendar units a `DATE_HISTOGRAM` group may bucket by. */\n dateUnits: AggregationDateUnit[];\n /** The calendar parts a `DATE_PART` group may group by. */\n dateParts: AggregationDatePart[];\n /** The units a `DATE_DIFF` may measure in; empty when `expressions` is `false`. */\n dateDiffUnits: DateDiffUnit[];\n /**\n * The field `FIRST` and `LAST` order by when they name no `orderBy`, at\n * the record level: the model's event time. Absent when the model has no\n * event time or the storage offers no `FIRST` / `LAST`. An explicit\n * `orderBy` may be any single-valued field whose `sort.paged` is `true` in\n * the metric's scope.\n */\n firstLastOrderBy?: string;\n /**\n * The window functions a derived metric may compute over the groups; empty\n * when expensive operators are off. Absent from servers before Wow 9.9,\n * which compute no windows.\n */\n windows?: WindowFunction[];\n /**\n * Whether a group of a query that expands elements may name a field of the\n * root record (`scope: 'root'`); `false` when expensive operators are off.\n * Absent from servers before Wow 9.9, which group elements by element\n * fields only.\n */\n rootGroups?: boolean;\n}\n\n/** A rule about combinations that no single capability shows. */\nexport interface ConstraintDescriptor {\n /** Which rule; see {@link QueryConstraintTypes}. */\n type: QueryConstraintType;\n /** For `CURSOR_UNIQUE_SORT`, the field the server appends to the sort. */\n appended?: string;\n /**\n * The fields the rule is about, when it names several: for\n * `PARALLEL_ARRAY_SORT`, the array fields a sort may name only one of;\n * for `NULL_OR_EMPTY_AS_MISSING`, the fields whose `null` or empty value\n * reads as missing.\n */\n fields?: string[];\n}\n\n/**\n * One variant of an element: the value of its discriminator and the fields\n * that variant has. For an event stream, one event type and its payload\n * fields.\n */\nexport interface VariantDescriptor {\n /** The discriminator's value, such as the event's `bodyType`. */\n value: string;\n /**\n * The variant's fields, by paths relative to the element, such as\n * `body.added.productId` inside `body`. Each field states the variant's\n * own types; its operators, sorts and aggregation are those of the shared\n * logical path, which admission checks. A field's `scope` is relative to\n * the element too, and absent for a field directly in it.\n */\n fields: FieldDescriptor[];\n /** What the variant means, when the model describes it. */\n description?: string;\n}\n\n/**\n * An element of every record whose fields differ by variant: an event\n * stream record's `body` holds events whose payload fields depend on\n * `bodyType`. A condition on one variant's field goes inside an\n * `ELEMENT_MATCH` on `element`, together with a condition on the\n * `discriminator`, so both hold for the same element.\n */\nexport interface VariantsDescriptor {\n /** The element's logical path, such as `body`. */\n element: string;\n /** The element-relative field that names each element's variant, such as `bodyType`. */\n discriminator: string;\n /** Each variant, sorted by `value`. */\n values: VariantDescriptor[];\n}\n\n/**\n * How a query model can be queried over HTTP: the answer\n * `GET {aggregate}/snapshot/schema` and `GET {aggregate}/event/schema` give.\n * Read it with `QueryDescriptorClient`.\n *\n * The contract: every operator, sort, paging mode, group and function it\n * lists is admitted when used on its own, and anything it does not list is\n * rejected; `constraints` names the rules about combinations. A value, a\n * scope or a policy can still reject a query, with a\n * `QueryViolation`. It exposes no storage names and does not depend on\n * the caller, so it can be cached: `version` is a hash of its content and is\n * also the response's ETag.\n */\nexport interface QueryModelDescriptor {\n /** The query model it describes. */\n model: QueryModel;\n /** `sha256:` and the hash of its content; also the ETag, quoted. */\n version: string;\n /** The zone a request that names none is read in: UTC (review R4-Q, Q-10). */\n timeZone: string;\n /** What holds for the records as a whole. */\n record: RecordDescriptor;\n /** The entry's effective limits. */\n limits: LimitsDescriptor;\n /** The aggregation features. */\n analysis: AnalysisDescriptor;\n /** Every queryable field, those inside elements included (see `scope`). */\n fields: FieldDescriptor[];\n /** The array fields whose elements can be queried one by one. */\n elements: ElementDescriptor[];\n /** Fields under dynamic map keys. */\n dynamic: DynamicFieldDescriptor[];\n /** The rules about combinations. */\n constraints: ConstraintDescriptor[];\n /**\n * The variants of an element whose fields differ by a discriminator, such\n * as an event stream's event types; absent when the model has none, as a\n * snapshot model never does.\n */\n variants?: VariantsDescriptor;\n}\n"],"mappings":"AAmDA,IAAaA,EAAc,OAAO,OAAO,CAEvC,SAAU,WAEV,aAAc,SAEd,QAAS,SACX,CAAU,EAUGC,EAAkB,OAAO,OAAO,CAE3C,OAAQ,SAER,QAAS,UAET,QAAS,UAET,QAAS,UAET,OAAQ,QACV,CAAU,EAOEC,EAAL,SAAA,EAAA,C,MAEL,GAAAC,QAAA,UAEA,EAAAC,KAAA,OAEA,EAAAC,OAAA,SAEA,EAAAC,OAAA,SAEA,EAAAC,MAAA,QAEA,EAAAC,MAAA,Q,CACF,EAAA,CAAA,CAAA,EAGYC,EAAL,SAAA,EAAA,C,MAEL,GAAAC,KAAA,OAEA,EAAAC,MAAA,QAEA,EAAAC,OAAA,S,CACF,EAAA,CAAA,CAAA,EAOaC,EAAkB,OAAO,OAAO,CAE3C,SAAU,WAEV,aAAc,eAEd,UAAW,YAEX,SAAU,WAEV,SAAU,WAEV,QAAS,UAMT,WAAY,aAKZ,iBAAkB,kBACpB,CAAU,EAUGC,EAAuB,OAAO,OAAO,CAKhD,mBAAoB,qBAEpB,sBAAuB,wBAEvB,4BAA6B,8BAO7B,oBAAqB,sBAQrB,yBAA0B,2BAO1B,eAAgB,gBAClB,CAAU,EAYGC,EAAqB,OAAO,OAAO,CAE9C,cAAe,gBAEf,eAAgB,iBAEhB,mBAAoB,qBAEpB,QAAS,UAET,MAAO,QAEP,SAAU,WAEV,UAAW,WACb,CAAU,EAiJEC,EAAL,SAAA,EAAA,C,MAML,GAAAC,QAAA,UAKA,EAAAC,aAAA,e,CACF,EAAA,CAAA,CAAA,E"}
|
|
1
|
+
{"version":3,"file":"descriptor.cjs","names":["QueryModels","PagingMode","\"LIST\"","\"PAGED\"","\"CURSOR\"","QueryConstraintTypes"],"sources":["../../src/dsl/descriptor.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\n// The capability descriptor `GET {aggregate}/{snapshot|event}/schema`\n// answers with: `me.ahoo.wow.query.descriptor.QueryModelDescriptor`,\n// mirrored from `query/query/src/main/kotlin/me/ahoo/wow/query/descriptor/`;\n// a field's descriptors are in `fieldDescriptor.ts`, and the semantics of\n// `query/schema/QuerySemanticType.kt` in `semanticTypes.ts`.\n//\n// Kotlin leaves a null out of the JSON of every descriptor class annotated\n// `@JsonInclude(NON_NULL)`, so those properties are optional here; the\n// limits are not annotated and send `null`. A set the OpenAPI document\n// describes as a plain string is open: a known union plus `string & {}`.\n\nimport type { WindowFunction } from './aggregation/derived.js';\nimport type {\n AggregationDatePart,\n AggregationDateUnit,\n} from './aggregation/groups.js';\nimport type { AggregationMetricType } from './aggregation/metrics.js';\nimport type { DateDiffUnit } from './aggregation/types.js';\nimport type { DeletionState } from './deletionState.js';\nimport type {\n DynamicFieldDescriptor,\n FieldDescriptor,\n} from './fieldDescriptor.js';\nimport type { FilterOperator, SearchMode } from './filter/index.js';\n\n/**\n * A query model's capability descriptor and its version, the `ETag` of\n * `GET …/query`; `notModified` when the version given is still current.\n */\nexport type DescriptorResult =\n | {\n readonly notModified: false;\n readonly version?: string;\n readonly descriptor: QueryModelDescriptor;\n }\n | { readonly notModified: true; readonly version: string };\n\n/**\n * The query models Wow names in a descriptor's `model`. The set is open: a\n * server may register a model of its own, so a descriptor's `model` is a\n * {@link QueryModel}.\n */\nexport const QueryModels = Object.freeze({\n /** The snapshot query model: `{aggregate}/snapshot/*`. */\n SNAPSHOT: 'snapshot',\n /** The event stream query model: `{aggregate}/event/*`. */\n EVENT_STREAM: 'events',\n /** A declared dataset, such as a ClickHouse wide table: `dataset/{context}/{dataset}/*`. */\n DATASET: 'dataset',\n} as const);\n\n/** A query model's name: one of {@link QueryModels}, or one a server added. */\nexport type QueryModel =\n (typeof QueryModels)[keyof typeof QueryModels] | (string & {});\n\n/** The ways a model can be read page by page, listed in `record.paging`. */\nexport enum PagingMode {\n /** `list` and `stream`: the first `limit` rows. */\n LIST = 'list',\n /** `paged`: numbered pages with a total. */\n PAGED = 'paged',\n /** `cursor`: forward-only pages after the last row seen. */\n CURSOR = 'cursor',\n}\n\n/**\n * The combination rules Wow names in a descriptor's `constraints`: rules\n * that no single capability shows. The set is open, like {@link QueryModels}.\n */\nexport const QueryConstraintTypes = Object.freeze({\n /**\n * A cursor's sort always ends with the identity field; the server appends\n * it (the constraint's `appended`) when the sort does not.\n */\n CURSOR_UNIQUE_SORT: 'cursor-unique-sort',\n /** A count or paged query must not match every record. */\n COUNT_REQUIRES_FILTER: 'count-requires-filter',\n /** `STARTS_WITH` needs a non-empty, case-sensitive prefix. */\n STARTS_WITH_REQUIRES_PREFIX: 'starts-with-requires-prefix',\n /**\n * A sort names at most one of the constraint's `fields`: they are\n * array-valued and the storage cannot order by two independent arrays.\n * Fields on one array path, one nested in the other, may still combine.\n * A sort that breaks it is refused with `PARALLEL_ARRAY_SORT`.\n */\n PARALLEL_ARRAY_SORT: 'parallel-array-sort',\n /**\n * On the constraint's `fields`, a stored `null` or empty array cannot be\n * told from a missing field: `EXISTS` does not match it, `NOT_EXISTS` and\n * `IS_NULL` do, and `IS_EMPTY` also matches a missing or `null` field. A\n * presence filter on such a field answers \"has a non-empty value\", not\n * \"has the key\"; say so to a user who writes one.\n */\n NULL_OR_EMPTY_AS_MISSING: 'null-or-empty-as-missing',\n /**\n * Model-wide, without `fields`: `EQ` and `NE` take only a scalar operand,\n * because the storage cannot compare a whole array. Match an array\n * field's elements instead (`IN`, `CONTAINS_ALL`, `ELEMENT_MATCH`); an `EQ` or\n * `NE` with an array operand is refused with `ARRAY_EQUALITY`.\n */\n ARRAY_EQUALITY: 'array-equality',\n /**\n * The queries of an events model must name their aggregates: the\n * constraint's `fields` are the one field to name them by, `aggregateId`.\n * The service lists it where events are visible only per aggregate, and\n * refuses a query that names none.\n */\n AGGREGATE_REQUIRED: 'aggregate-required',\n} as const);\n\n/** A constraint's type: one of {@link QueryConstraintTypes}, or one a server added. */\nexport type QueryConstraintType =\n | (typeof QueryConstraintTypes)[keyof typeof QueryConstraintTypes]\n | (string & {});\n\n/** An array field whose elements can be filtered or aggregated one by one. */\nexport interface ElementDescriptor {\n /** The array field's logical path. */\n path: string;\n /** Whether `ELEMENT_MATCH` may filter its elements. */\n filter: boolean;\n /** Whether an aggregation may run over its elements. */\n aggregate: boolean;\n /**\n * Full-text search on its fields: a `SEARCH` that names them, relative\n * to the element, inside an `ELEMENT_MATCH` on it. Absent when the\n * storage can search none of them, as on MongoDB.\n */\n search?: SearchDescriptor;\n}\n\n/**\n * Full-text search in one scope: the record's (`record.search`) or an\n * element's (`elements[].search`).\n */\nexport interface SearchDescriptor {\n /**\n * For the record, the modes of a model-wide `SEARCH` (without fields);\n * empty when one of its fields is not comparable, since a search across\n * the model would match that field. For an element, the modes every\n * listed field accepts.\n */\n modes: (SearchMode | (string & {}))[];\n /**\n * The fields a `SEARCH` may name, by full logical path; never one that is\n * not comparable. For the record, only record-level fields, never one\n * inside an element; for an element, its own fields, which the query\n * writes relative to the element.\n */\n fields: string[];\n}\n\n/** What holds for the model's records as a whole. */\nexport interface RecordDescriptor {\n /** The logical path of the field that identifies a record. */\n identity: string;\n /** The ways the model can be read page by page. */\n paging: (PagingMode | (string & {}))[];\n /** The deletion scope a query without one gets; absent when the model has none. */\n defaultScope?: DeletionState;\n /**\n * Operators that name no field of their own: the system-field ones, such\n * as `ID` or `TENANT_ID`, and `EXPRESSION`, whose expression names its\n * fields, where the server allows expensive operators.\n */\n rootOperators: (FilterOperator | (string & {}))[];\n /** Model-wide full-text search; absent when the model offers none. */\n search?: SearchDescriptor;\n}\n\n/** The fixed limits of an aggregation query. */\nexport interface AggregationLimitsDescriptor {\n /** Most groups in `groupBy`. */\n maxGroups: number;\n /** Most metrics. */\n maxMetrics: number;\n /** Most elements an aggregation runs over. */\n maxElements: number;\n /** Largest `limit` on the result rows. */\n maxLimit: number;\n /** Deepest arithmetic expression. */\n maxExpressionDepth: number;\n /** Most nodes in one arithmetic expression. */\n maxExpressionNodes: number;\n /**\n * The most groups an aggregation may read where the server computes part of\n * it (HAVING, a metric sort, dense fill or windows its storage cannot run),\n * beyond which the query fails; `null` or absent is unlimited. Absent from\n * servers before Wow 9.10.\n */\n maxResidualGroups?: number | null;\n}\n\n/**\n * The effective limits of the entry the descriptor was read from: the\n * protocol's and the entry's budget, whichever is smaller. `null` is\n * unlimited.\n */\nexport interface LimitsDescriptor {\n /** Largest `limit` of a list query. */\n maxListSize: number | null;\n /**\n * The `limit` a list query without one gets. A cursor query without a\n * `size` gets the same default, at most `maxPageSize`.\n */\n defaultListSize: number | null;\n /** Largest page `size` of a paged or cursor query. */\n maxPageSize: number | null;\n /** How far a paged query may reach: page index times size. */\n maxPageWindow: number | null;\n /** Most nodes in one filter. */\n maxFilterNodes: number | null;\n /** Most values in one filter, `IN` lists included. */\n maxFilterValues: number | null;\n /** Most fields in one sort. */\n maxSortFields: number;\n /** The limits of an aggregation query. */\n aggregation: AggregationLimitsDescriptor;\n}\n\n/** The metrics a `having` clause may test. */\nexport interface HavingDescriptor {\n /** The metric types it may name; never `ANY`, `FIRST` or `LAST`. */\n metrics: (AggregationMetricType | (string & {}))[];\n}\n\n/** What an aggregation's result rows may be sorted by. */\nexport interface AnalysisSortDescriptor {\n /** By a group. */\n groups: boolean;\n /** By a metric. */\n metrics: boolean;\n}\n\n/** The aggregation features the model offers. */\nexport interface AnalysisDescriptor {\n /** The metric types it admits. */\n metrics: (AggregationMetricType | (string & {}))[];\n /**\n * The metric types among `metrics` whose results this backend estimates\n * rather than computes exactly, such as `PERCENTILE` on MongoDB, or\n * `DISTINCT_COUNT` and `PERCENTILE` on Elasticsearch; empty when every\n * result is exact. The set is open, like `metrics`: label a result of a\n * listed type as approximate.\n */\n approximate: (AggregationMetricType | (string & {}))[];\n /**\n * Whether computed expressions (arithmetic and `DATE_DIFF`) may feed\n * metrics and TERMS / HISTOGRAM groups, and be compared by an `EXPRESSION`\n * filter. A `DATE_DIFF` operand is any field whose `aggregate.groups`\n * lists `DATE_HISTOGRAM`.\n */\n expressions: boolean;\n /** What `having` may test. */\n having: HavingDescriptor;\n /** What result rows may be sorted by. */\n sort: AnalysisSortDescriptor;\n /**\n * Whether a date histogram or a date part group may fill its empty\n * buckets (`dense`).\n */\n dense: boolean;\n /** The calendar units a `DATE_HISTOGRAM` group may bucket by. */\n dateUnits: (AggregationDateUnit | (string & {}))[];\n /** The calendar parts a `DATE_PART` group may group by. */\n dateParts: (AggregationDatePart | (string & {}))[];\n /** The units a `DATE_DIFF` may measure in; empty when `expressions` is `false`. */\n dateDiffUnits: (DateDiffUnit | (string & {}))[];\n /**\n * The field `FIRST` and `LAST` order by when they name no `orderBy`, at\n * the record level: the model's event time. Absent when the model has no\n * event time or the storage offers no `FIRST` / `LAST`. An explicit\n * `orderBy` may be any single-valued field whose `sort.paged` is `true` in\n * the metric's scope.\n */\n firstLastOrderBy?: string;\n /**\n * The window functions a derived metric may compute over the groups; empty\n * when expensive operators are off. Absent from servers before Wow 9.9,\n * which compute no windows.\n */\n windows?: (WindowFunction | (string & {}))[];\n /**\n * Whether a group of a query that expands elements may name a field of the\n * root record (`scope: 'root'`); `false` when expensive operators are off.\n * Absent from servers before Wow 9.9, which group elements by element\n * fields only.\n */\n rootGroups?: boolean;\n}\n\n/** A rule about combinations that no single capability shows. */\nexport interface ConstraintDescriptor {\n /** Which rule; see {@link QueryConstraintTypes}. */\n type: QueryConstraintType;\n /** For `CURSOR_UNIQUE_SORT`, the field the server appends to the sort. */\n appended?: string;\n /**\n * The fields the rule is about, when it names several: for\n * `PARALLEL_ARRAY_SORT`, the array fields a sort may name only one of;\n * for `NULL_OR_EMPTY_AS_MISSING`, the fields whose `null` or empty value\n * reads as missing.\n */\n fields?: string[];\n}\n\n/**\n * One variant of an element: the value of its discriminator and the fields\n * that variant has. For an event stream, one event type and its payload\n * fields.\n */\nexport interface VariantDescriptor {\n /** The discriminator's value, such as the event's `bodyType`. */\n value: string;\n /**\n * The variant's fields, by paths relative to the element, such as\n * `body.added.productId` inside `body`. Each field states the variant's\n * own types; its operators, sorts and aggregation are those of the shared\n * logical path, which admission checks. A field's `scope` is relative to\n * the element too, and absent for a field directly in it.\n */\n fields: FieldDescriptor[];\n /** What the variant means, when the model describes it. */\n description?: string;\n}\n\n/**\n * An element of every record whose fields differ by variant: an event\n * stream record's `body` holds events whose payload fields depend on\n * `bodyType`. A condition on one variant's field goes inside an\n * `ELEMENT_MATCH` on `element`, together with a condition on the\n * `discriminator`, so both hold for the same element.\n */\nexport interface VariantsDescriptor {\n /** The element's logical path, such as `body`. */\n element: string;\n /** The element-relative field that names each element's variant, such as `bodyType`. */\n discriminator: string;\n /** Each variant, sorted by `value`. */\n values: VariantDescriptor[];\n}\n\n/**\n * How a query model can be queried over HTTP: the answer\n * `GET {aggregate}/snapshot/schema` and `GET {aggregate}/event/schema` give.\n * Read it with `QueryDescriptorClient`.\n *\n * The contract: every operator, sort, paging mode, group and function it\n * lists is admitted when used on its own, and anything it does not list is\n * rejected; `constraints` names the rules about combinations. A value, a\n * scope or a policy can still reject a query, with a\n * `QueryViolation`. It exposes no storage names and does not depend on\n * the caller, so it can be cached: `version` is a hash of its content and is\n * also the response's ETag.\n */\nexport interface QueryModelDescriptor {\n /** The query model it describes. */\n model: QueryModel;\n /** `sha256:` and the hash of its content; also the ETag, quoted. */\n version: string;\n /** The zone a request that names none is read in: UTC (review R4-Q, Q-10). */\n timeZone: string;\n /** What holds for the records as a whole. */\n record: RecordDescriptor;\n /** The entry's effective limits. */\n limits: LimitsDescriptor;\n /** The aggregation features. */\n analysis: AnalysisDescriptor;\n /** Every queryable field, those inside elements included (see `scope`). */\n fields: FieldDescriptor[];\n /** The array fields whose elements can be queried one by one. */\n elements: ElementDescriptor[];\n /** Fields under dynamic map keys. */\n dynamic: DynamicFieldDescriptor[];\n /** The rules about combinations. */\n constraints: ConstraintDescriptor[];\n /**\n * The variants of an element whose fields differ by a discriminator, such\n * as an event stream's event types; absent when the model has none, as a\n * snapshot model never does.\n */\n variants?: VariantsDescriptor;\n}\n"],"mappings":"AAuDA,IAAaA,EAAc,OAAO,OAAO,CAEvC,SAAU,WAEV,aAAc,SAEd,QAAS,SACX,CAAU,EAOEC,EAAL,SAAA,EAAA,C,MAEL,GAAAC,KAAA,OAEA,EAAAC,MAAA,QAEA,EAAAC,OAAA,S,CACF,EAAA,CAAA,CAAA,EAMaC,EAAuB,OAAO,OAAO,CAKhD,mBAAoB,qBAEpB,sBAAuB,wBAEvB,4BAA6B,8BAO7B,oBAAqB,sBAQrB,yBAA0B,2BAO1B,eAAgB,iBAOhB,mBAAoB,oBACtB,CAAU,E"}
|