@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeFilters.es.js","names":["calendar","validateRelativeTimeOptions","options","queryField","field","dayWindow","validateDays","op","days","nowRelative","requireDuration","offset","timeFilters","FilterOperator","localTime","requireLocalTime","time"],"sources":["../../../src/dsl/filter/timeFilters.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 { queryField } from '../field.js';\nimport { FilterOperator } from './operator.js';\nimport type {\n BeforeTodayFilter,\n CalendarFilter,\n DaysFilter,\n NowFilter,\n RelativeTimeFilterOptions,\n} from './types.js';\nimport {\n requireLocalTime,\n requireDuration,\n validateDays,\n validateRelativeTimeOptions,\n} from './validate.js';\n\nfunction calendar<FIELDS extends string>(\n op: CalendarFilter['op'],\n field: FIELDS,\n options: RelativeTimeFilterOptions,\n): CalendarFilter<FIELDS> {\n return {\n ...validateRelativeTimeOptions(options),\n op,\n field: queryField(field),\n };\n}\n\nfunction dayWindow<FIELDS extends string>(\n op: DaysFilter['op'],\n field: FIELDS,\n days: number,\n options: RelativeTimeFilterOptions,\n): DaysFilter<FIELDS> {\n validateDays(op, days);\n return {\n ...validateRelativeTimeOptions(options),\n op,\n field: queryField(field),\n days,\n };\n}\n\nfunction nowRelative<FIELDS extends string>(\n op: NowFilter['op'],\n field: FIELDS,\n offset: string,\n options: RelativeTimeFilterOptions,\n): NowFilter<FIELDS> {\n requireDuration(op, offset);\n return {\n ...validateRelativeTimeOptions(options),\n op,\n field: queryField(field),\n offset,\n };\n}\n\n/** The filters on a time field: calendar periods, days relative to today, and instants relative to the server's now. */\nexport const timeFilters = {\n /**\n * Matches times within today, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'today', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.today('state.createTime', { timeZone: 'Asia/Shanghai' });\n * ```\n */\n today<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.TODAY, field, options);\n },\n /**\n * Matches times earlier than today at the local time `time`\n * (`field < today at time`) in the configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param time - 24-hour local time: `HH:mm`, `HH:mm:ss` or `HH:mm:ss.S` with\n * 1 to 9 fraction digits.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'before-today', field, time }`, plus `timeZone` when set.\n * @throws TypeError If `time` is not a string in one of the formats above,\n * `field` is not a valid query field path, or `timeZone` is blank or an\n * invalid UTC offset.\n * @example\n * ```typescript\n * filter.beforeToday('state.createTime', '12:00');\n * ```\n */\n beforeToday<FIELDS extends string>(\n field: FIELDS,\n time: string,\n options: RelativeTimeFilterOptions = {},\n ): BeforeTodayFilter<FIELDS> {\n const localTime = requireLocalTime(time);\n return {\n ...validateRelativeTimeOptions(options),\n op: FilterOperator.BEFORE_TODAY,\n field: queryField(field),\n time: localTime,\n };\n },\n /**\n * Matches times within tomorrow, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'tomorrow', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.tomorrow('state.createTime');\n * ```\n */\n tomorrow<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.TOMORROW, field, options);\n },\n /**\n * Matches times within the current Monday-start week, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'this-week', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.thisWeek('state.createTime');\n * ```\n */\n thisWeek<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.THIS_WEEK, field, options);\n },\n /**\n * Matches times within the next Monday-start week, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'next-week', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.nextWeek('state.createTime');\n * ```\n */\n nextWeek<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.NEXT_WEEK, field, options);\n },\n /**\n * Matches times within the previous Monday-start week, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'last-week', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.lastWeek('state.createTime');\n * ```\n */\n lastWeek<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.LAST_WEEK, field, options);\n },\n /**\n * Matches times within the current calendar month, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'this-month', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.thisMonth('state.createTime');\n * ```\n */\n thisMonth<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.THIS_MONTH, field, options);\n },\n /**\n * Matches times within the previous calendar month, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'last-month', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.lastMonth('state.createTime');\n * ```\n */\n lastMonth<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.LAST_MONTH, field, options);\n },\n /**\n * Matches times within yesterday, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'yesterday', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.yesterday('state.createTime');\n * ```\n */\n yesterday<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.YESTERDAY, field, options);\n },\n /**\n * Matches times within the next calendar month, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'next-month', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.nextMonth('state.createTime');\n * ```\n */\n nextMonth<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.NEXT_MONTH, field, options);\n },\n /**\n * Matches times within the previous calendar year, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'last-year', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.lastYear('state.createTime');\n * ```\n */\n lastYear<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.LAST_YEAR, field, options);\n },\n /**\n * Matches times within the current calendar year, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'this-year', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.thisYear('state.createTime', { timeZone: 'Asia/Shanghai' });\n * ```\n */\n thisYear<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.THIS_YEAR, field, options);\n },\n /**\n * Matches times within the next calendar year, as the half-open range `[start, end)` in the\n * configured time zone.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'next-year', field }`, plus `timeZone` when set.\n * @throws TypeError If `field` is not a valid query field path, or `timeZone` is\n * blank or an invalid UTC offset.\n * @example\n * ```typescript\n * filter.nextYear('state.createTime');\n * ```\n */\n nextYear<FIELDS extends string>(\n field: FIELDS,\n options: RelativeTimeFilterOptions = {},\n ): CalendarFilter<FIELDS> {\n return calendar(FilterOperator.NEXT_YEAR, field, options);\n },\n /**\n * Matches times from the start of the day `days - 1` days ago until the end\n * of today. `recentDays(field, 7)` covers today and the six previous days.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param days - Number of calendar days, including today; an integer from\n * 1 to 2147483647.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'recent-days', field, days }`, plus `timeZone` when set.\n * @throws TypeError If `days` is not an integer from 1 to 2147483647,\n * `field` is not a valid query field path, or `timeZone` is blank or an\n * invalid UTC offset.\n * @example\n * ```typescript\n * filter.recentDays('state.createTime', 7);\n * ```\n */\n recentDays<FIELDS extends string>(\n field: FIELDS,\n days: number,\n options: RelativeTimeFilterOptions = {},\n ): DaysFilter<FIELDS> {\n return dayWindow(FilterOperator.RECENT_DAYS, field, days, options);\n },\n /**\n * Matches times before the start of the day `days - 1` days ago, that is,\n * before the window that `recentDays` covers with the same `days`.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param days - Number of calendar days, including today; an integer from\n * 1 to 2147483647.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'earlier-days', field, days }`, plus `timeZone` when set.\n * @throws TypeError If `days` is not an integer from 1 to 2147483647,\n * `field` is not a valid query field path, or `timeZone` is blank or an\n * invalid UTC offset.\n * @example\n * ```typescript\n * filter.earlierDays('state.createTime', 7);\n * ```\n */\n earlierDays<FIELDS extends string>(\n field: FIELDS,\n days: number,\n options: RelativeTimeFilterOptions = {},\n ): DaysFilter<FIELDS> {\n return dayWindow(FilterOperator.EARLIER_DAYS, field, days, options);\n },\n /**\n * Matches times strictly before the server's `now + offset`\n * (`field < now + offset`). The server reads its clock once per query,\n * so a saved query never depends on the client's clock, and the moment is\n * encoded the way the query schema says the field stores time: an epoch in\n * its unit, or text in its pattern, in the zone `timeZone` names.\n *\n * Needs a Wow server of 9.2.0 or later; an earlier one refuses `BEFORE_NOW`.\n *\n * @param field - Query field path, e.g. `state.timeoutAt`.\n * @param offset - ISO-8601 duration added to now, as\n * `java.time.Duration.parse` reads it: days, hours, minutes and seconds,\n * each optionally signed, e.g. `PT0S`, `-PT30M` or `P1DT2H`. A negative\n * offset looks back. Defaults to `PT0S`, now itself.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'before-now', field, offset }`, plus `timeZone` when set.\n * @throws TypeError If `offset` is not an ISO-8601 duration in that\n * grammar, `field` is not a valid query field path, or `timeZone` is blank\n * or an invalid UTC offset.\n * @example\n * ```typescript\n * // Timed out: the deadline has passed.\n * filter.beforeNow('state.timeoutAt');\n * ```\n */\n beforeNow<FIELDS extends string>(\n field: FIELDS,\n offset = 'PT0S',\n options: RelativeTimeFilterOptions = {},\n ): NowFilter<FIELDS> {\n return nowRelative(FilterOperator.BEFORE_NOW, field, offset, options);\n },\n /**\n * Matches times strictly after the server's `now + offset`\n * (`field > now + offset`). The server reads its clock once per query,\n * so a saved query never depends on the client's clock, and the moment is\n * encoded the way the query schema says the field stores time: an epoch in\n * its unit, or text in its pattern, in the zone `timeZone` names.\n *\n * Needs a Wow server of 9.2.0 or later; an earlier one refuses `AFTER_NOW`.\n *\n * @param field - Query field path, e.g. `state.timeoutAt`.\n * @param offset - ISO-8601 duration added to now, as\n * `java.time.Duration.parse` reads it: days, hours, minutes and seconds,\n * each optionally signed, e.g. `PT0S`, `-PT30M` or `P1DT2H`. A negative\n * offset looks back. Defaults to `PT0S`, now itself.\n * @param options - Optional `timeZone`; see {@link RelativeTimeFilterOptions}.\n * @returns `{ op: 'after-now', field, offset }`, plus `timeZone` when set.\n * @throws TypeError If `offset` is not an ISO-8601 duration in that\n * grammar, `field` is not a valid query field path, or `timeZone` is blank\n * or an invalid UTC offset.\n * @example\n * ```typescript\n * // Created in the last 30 minutes.\n * filter.afterNow('state.createTime', '-PT30M');\n * ```\n */\n afterNow<FIELDS extends string>(\n field: FIELDS,\n offset = 'PT0S',\n options: RelativeTimeFilterOptions = {},\n ): NowFilter<FIELDS> {\n return nowRelative(FilterOperator.AFTER_NOW, field, offset, options);\n },\n};\n"],"mappings":";;;;AA6BA,SAASA,EACP,GACA,GACA,GACwB;CACxB,OAAO;EACL,GAAGC,EAA4BC,CAAO;EACtC;EACA,OAAOC,EAAWC,CAAK;CACzB;AACF;AAEA,SAASC,EACP,GACA,GACA,GACA,GACoB;CAEpB,OADAC,EAAaC,GAAIC,CAAI,GACd;EACL,GAAGP,EAA4BC,CAAO;EACtC;EACA,OAAOC,EAAWC,CAAK;EACvB;CACF;AACF;AAEA,SAASK,EACP,GACA,GACA,GACA,GACmB;CAEnB,OADAC,EAAgBH,GAAII,CAAM,GACnB;EACL,GAAGV,EAA4BC,CAAO;EACtC;EACA,OAAOC,EAAWC,CAAK;EACvB;CACF;AACF;AAGA,IAAaQ,IAAc;CAezB,MACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOZ,EAASa,EAAe,OAAOT,GAAOF,CAAO;CACtD;CAkBA,YACE,GACA,GACA,IAAqC,CAAC,GACX;EAC3B,IAAMY,IAAYC,EAAiBC,CAAI;EACvC,OAAO;GACL,GAAGf,EAA4BC,CAAO;GACtC,IAAIW,EAAe;GACnB,OAAOV,EAAWC,CAAK;GACvB,MAAMU;EACR;CACF;CAeA,SACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOd,EAASa,EAAe,UAAUT,GAAOF,CAAO;CACzD;CAeA,SACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOF,EAASa,EAAe,WAAWT,GAAOF,CAAO;CAC1D;CAeA,SACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOF,EAASa,EAAe,WAAWT,GAAOF,CAAO;CAC1D;CAeA,SACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOF,EAASa,EAAe,WAAWT,GAAOF,CAAO;CAC1D;CAeA,UACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOF,EAASa,EAAe,YAAYT,GAAOF,CAAO;CAC3D;CAeA,UACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOF,EAASa,EAAe,YAAYT,GAAOF,CAAO;CAC3D;CAeA,UACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOF,EAASa,EAAe,WAAWT,GAAOF,CAAO;CAC1D;CAeA,UACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOF,EAASa,EAAe,YAAYT,GAAOF,CAAO;CAC3D;CAeA,SACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOF,EAASa,EAAe,WAAWT,GAAOF,CAAO;CAC1D;CAeA,SACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOF,EAASa,EAAe,WAAWT,GAAOF,CAAO;CAC1D;CAeA,SACE,GACA,IAAqC,CAAC,GACd;EACxB,OAAOF,EAASa,EAAe,WAAWT,GAAOF,CAAO;CAC1D;CAkBA,WACE,GACA,GACA,IAAqC,CAAC,GAClB;EACpB,OAAOG,EAAUQ,EAAe,aAAaT,GAAOI,GAAMN,CAAO;CACnE;CAkBA,YACE,GACA,GACA,IAAqC,CAAC,GAClB;EACpB,OAAOG,EAAUQ,EAAe,cAAcT,GAAOI,GAAMN,CAAO;CACpE;CA0BA,UACE,GACA,IAAS,QACT,IAAqC,CAAC,GACnB;EACnB,OAAOO,EAAYI,EAAe,YAAYT,GAAOO,GAAQT,CAAO;CACtE;CA0BA,SACE,GACA,IAAS,QACT,IAAqC,CAAC,GACnB;EACnB,OAAOO,EAAYI,EAAe,WAAWT,GAAOO,GAAQT,CAAO;CACrE;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AggregationExpression, ComparisonOperator } from '../aggregation/types.cjs';
|
|
2
2
|
import { DeletionState } from '../deletionState.cjs';
|
|
3
|
-
import { FilterOperator, SearchMode, StringComparison
|
|
3
|
+
import { FilterOperator, SearchMode, StringComparison } from './operator.cjs';
|
|
4
4
|
/**
|
|
5
5
|
* Dot-separated logical field path. The first segment is a name; later
|
|
6
6
|
* segments are names or decimal array indexes. A name may start with `@`,
|
|
@@ -169,7 +169,8 @@ export interface SearchFilterOptions<FIELDS extends string = string> {
|
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* Options shared by relative time filters. Unset options are omitted from
|
|
172
|
-
* the payload
|
|
172
|
+
* the payload. How the window's bounds are written is the field's: the
|
|
173
|
+
* server writes them as the query schema says the field keeps time.
|
|
173
174
|
*/
|
|
174
175
|
export interface RelativeTimeFilterOptions {
|
|
175
176
|
/**
|
|
@@ -180,18 +181,7 @@ export interface RelativeTimeFilterOptions {
|
|
|
180
181
|
* or `-` must be a valid offset within +/-18:00; region IDs are checked by
|
|
181
182
|
* the server only.
|
|
182
183
|
*/
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* `java.time.format.DateTimeFormatter` pattern for fields stored as
|
|
186
|
-
* formatted strings, e.g. `yyyy-MM-dd`. Must equal the pattern declared by
|
|
187
|
-
* the query schema. Must not be blank.
|
|
188
|
-
*/
|
|
189
|
-
datePattern?: string;
|
|
190
|
-
/**
|
|
191
|
-
* Unit of a numeric epoch field. Defaults to `TimeUnit.MILLISECONDS`.
|
|
192
|
-
* Ignored when `datePattern` is set.
|
|
193
|
-
*/
|
|
194
|
-
timeUnit?: TimeUnit;
|
|
184
|
+
timeZone?: string;
|
|
195
185
|
}
|
|
196
186
|
/**
|
|
197
187
|
* Matches times in a calendar window relative to now: `[start, end)` in the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AggregationExpression, ComparisonOperator } from '../aggregation/types.js';
|
|
2
2
|
import { DeletionState } from '../deletionState.js';
|
|
3
|
-
import { FilterOperator, SearchMode, StringComparison
|
|
3
|
+
import { FilterOperator, SearchMode, StringComparison } from './operator.js';
|
|
4
4
|
/**
|
|
5
5
|
* Dot-separated logical field path. The first segment is a name; later
|
|
6
6
|
* segments are names or decimal array indexes. A name may start with `@`,
|
|
@@ -169,7 +169,8 @@ export interface SearchFilterOptions<FIELDS extends string = string> {
|
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* Options shared by relative time filters. Unset options are omitted from
|
|
172
|
-
* the payload
|
|
172
|
+
* the payload. How the window's bounds are written is the field's: the
|
|
173
|
+
* server writes them as the query schema says the field keeps time.
|
|
173
174
|
*/
|
|
174
175
|
export interface RelativeTimeFilterOptions {
|
|
175
176
|
/**
|
|
@@ -180,18 +181,7 @@ export interface RelativeTimeFilterOptions {
|
|
|
180
181
|
* or `-` must be a valid offset within +/-18:00; region IDs are checked by
|
|
181
182
|
* the server only.
|
|
182
183
|
*/
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* `java.time.format.DateTimeFormatter` pattern for fields stored as
|
|
186
|
-
* formatted strings, e.g. `yyyy-MM-dd`. Must equal the pattern declared by
|
|
187
|
-
* the query schema. Must not be blank.
|
|
188
|
-
*/
|
|
189
|
-
datePattern?: string;
|
|
190
|
-
/**
|
|
191
|
-
* Unit of a numeric epoch field. Defaults to `TimeUnit.MILLISECONDS`.
|
|
192
|
-
* Ignored when `datePattern` is set.
|
|
193
|
-
*/
|
|
194
|
-
timeUnit?: TimeUnit;
|
|
184
|
+
timeZone?: string;
|
|
195
185
|
}
|
|
196
186
|
/**
|
|
197
187
|
* Matches times in a calendar window relative to now: `[start, end)` in the
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./operator.cjs"),t=require("../constantName.cjs")
|
|
1
|
+
const e=require("./operator.cjs"),t=require("../constantName.cjs");var n=/^([01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?$/,r=/^(?:UTC|GMT|UT)?[+-](\d{1,2}|\d{4}|\d{6}|\d{2}:\d{2}|\d{2}:\d{2}:\d{2})$/,i=/^(?:UTC|GMT|UT)?[+-]/,a=/^[-+]?P(?=.*[0-9])(?:[-+]?[0-9]+D)?(?:T(?=[-+]?[0-9])(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$/i;function o(e,t){if(!(e===null?t:typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e)))throw TypeError(`Filter value must be a JSON scalar.`);return e}function s(e,t){if(typeof t!=`string`)throw TypeError(`${e} must be a string.`);return t}function c(t){if(t!==e.StringComparison.CASE_SENSITIVE&&t!==e.StringComparison.CASE_INSENSITIVE)throw TypeError(`String comparison is invalid: [${String(t)}].`)}function l(e,t){if(t.length===0)throw TypeError(`${e} cannot be empty.`);if(t.some(e=>e==null))throw TypeError(`${e} cannot contain null.`)}function u(e){let t=r.exec(e);if(!t)return!1;let n=t[1],[i,a=0,o=0]=(n.includes(`:`)?n.split(`:`):n.length<=2?[n]:[n.slice(0,2),n.slice(2,4),n.slice(4,6)]).map(Number);return a<=59&&o<=59&&(i<18||i===18&&a===0&&o===0)}function d({timeZone:e}){if(e!==void 0){if(typeof e!=`string`||!e.trim())throw TypeError(`timeZone cannot be blank.`);if(i.test(e)&&!u(e))throw TypeError(`timeZone is invalid: [${e}].`)}return e===void 0?{}:{timeZone:e}}function f(e,n){if(!Number.isInteger(n)||n<1||n>2147483647)throw TypeError(`${t.constantName(e)} days must be a positive JVM Int.`)}function p(e,n){if(typeof n!=`string`||!a.test(n))throw TypeError(`${t.constantName(e)} offset must be an ISO-8601 duration such as PT0S or -PT30M.`);return n}function m(e){if(typeof e!=`string`||!n.test(e))throw TypeError(`BEFORE_TODAY time is invalid.`);return e}exports.filterLiteral=o,exports.requireDuration=p,exports.requireLocalTime=m,exports.requireNonEmpty=l,exports.requiredString=s,exports.validateDays=f,exports.validateRelativeTimeOptions=d,exports.validateStringComparison=c;
|
|
2
2
|
//# sourceMappingURL=validate.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.cjs","names":["StringComparison","
|
|
1
|
+
{"version":3,"file":"validate.cjs","names":["StringComparison","constantName","require_operator","require_constantName","LOCAL_TIME_PATTERN","OFFSET_ZONE_PATTERN","OFFSET_ZONE_CANDIDATE_PATTERN","DURATION_PATTERN","filterLiteral","value","nullable","requiredString","name","validateStringComparison","comparison","requireNonEmpty","values","isValidOffsetZone","match","timeZone","offset","hours","minutes","seconds","validateRelativeTimeOptions","validateDays","days","operator","requireDuration","requireLocalTime","time"],"sources":["../../../src/dsl/filter/validate.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// Internal: not re-exported by filter/index.ts. The argument checks the\n// filter builders share.\nimport { constantName } from '../constantName.js';\nimport { StringComparison, type FilterOperator } from './operator.js';\nimport type { FilterLiteral, RelativeTimeFilterOptions } from './types.js';\n\nconst LOCAL_TIME_PATTERN =\n /^([01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\\.[0-9]{1,9})?)?$/;\nconst OFFSET_ZONE_PATTERN =\n /^(?:UTC|GMT|UT)?[+-](\\d{1,2}|\\d{4}|\\d{6}|\\d{2}:\\d{2}|\\d{2}:\\d{2}:\\d{2})$/;\nconst OFFSET_ZONE_CANDIDATE_PATTERN = /^(?:UTC|GMT|UT)?[+-]/;\n// java.time.Duration.parse: signed days, hours, minutes and seconds (up to\n// nine fraction digits after `.` or `,`), at least one of them, in that order,\n// case-insensitive. Weeks, months and years are not durations.\nconst DURATION_PATTERN =\n /^[-+]?P(?=.*[0-9])(?:[-+]?[0-9]+D)?(?:T(?=[-+]?[0-9])(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$/i;\n\nexport function filterLiteral<T extends FilterLiteral>(\n value: T,\n nullable: boolean,\n): T {\n const valid =\n value === null\n ? nullable\n : typeof value === 'string' ||\n typeof value === 'boolean' ||\n (typeof value === 'number' && Number.isFinite(value));\n if (!valid) {\n throw new TypeError('Filter value must be a JSON scalar.');\n }\n return value;\n}\n\nexport function requiredString(name: string, value: string): string {\n if (typeof value !== 'string') {\n throw new TypeError(`${name} must be a string.`);\n }\n return value;\n}\n\nexport function validateStringComparison(comparison: StringComparison): void {\n if (\n comparison !== StringComparison.CASE_SENSITIVE &&\n comparison !== StringComparison.CASE_INSENSITIVE\n ) {\n throw new TypeError(\n `String comparison is invalid: [${String(comparison)}].`,\n );\n }\n}\n\nexport function requireNonEmpty(\n name: string,\n values: readonly unknown[],\n): void {\n if (values.length === 0) {\n throw new TypeError(`${name} cannot be empty.`);\n }\n if (values.some(value => value === null || value === undefined)) {\n throw new TypeError(`${name} cannot contain null.`);\n }\n}\n\nfunction isValidOffsetZone(timeZone: string): boolean {\n const match = OFFSET_ZONE_PATTERN.exec(timeZone);\n if (!match) return false;\n const offset = match[1];\n const parts = offset.includes(':')\n ? offset.split(':')\n : offset.length <= 2\n ? [offset]\n : [offset.slice(0, 2), offset.slice(2, 4), offset.slice(4, 6)];\n const [hours, minutes = 0, seconds = 0] = parts.map(Number);\n return (\n minutes <= 59 &&\n seconds <= 59 &&\n (hours < 18 || (hours === 18 && minutes === 0 && seconds === 0))\n );\n}\n\nexport function validateRelativeTimeOptions({\n timeZone,\n}: RelativeTimeFilterOptions): RelativeTimeFilterOptions {\n if (timeZone !== undefined) {\n if (typeof timeZone !== 'string' || !timeZone.trim()) {\n throw new TypeError('timeZone cannot be blank.');\n }\n if (\n OFFSET_ZONE_CANDIDATE_PATTERN.test(timeZone) &&\n !isValidOffsetZone(timeZone)\n ) {\n throw new TypeError(`timeZone is invalid: [${timeZone}].`);\n }\n }\n return timeZone === undefined ? {} : { timeZone };\n}\n\nexport function validateDays(operator: FilterOperator, days: number): void {\n if (!Number.isInteger(days) || days < 1 || days > 2_147_483_647) {\n throw new TypeError(\n `${constantName(operator)} days must be a positive JVM Int.`,\n );\n }\n}\n\n/**\n * Admits the ISO-8601 duration `BEFORE_NOW` and `AFTER_NOW` add to the\n * server's now, in the grammar `java.time.Duration.parse` accepts. A value\n * too large for a `Duration` is left to the server.\n */\nexport function requireDuration(\n operator: FilterOperator,\n offset: string,\n): string {\n if (typeof offset !== 'string' || !DURATION_PATTERN.test(offset)) {\n throw new TypeError(\n `${constantName(operator)} offset must be an ISO-8601 duration such as PT0S or -PT30M.`,\n );\n }\n return offset;\n}\n\n/** Admits the 24-hour local time `BEFORE_TODAY` compares against. */\nexport function requireLocalTime(time: string): string {\n if (typeof time !== 'string' || !LOCAL_TIME_PATTERN.test(time)) {\n throw new TypeError('BEFORE_TODAY time is invalid.');\n }\n return time;\n}\n"],"mappings":"A,mEAmBA,IAAMI,EACJ,mEACIC,EACJ,2EACIC,EAAgC,uBAIhCC,EACJ,kIAEF,SAAgBC,EACd,EACA,EACG,CAOH,GAAI,EALFC,IAAU,KACNC,EACA,OAAOD,GAAU,UACjB,OAAOA,GAAU,WAChB,OAAOA,GAAU,UAAY,OAAO,SAASA,CAAK,GAEvD,MAAU,UAAU,qCAAqC,EAE3D,OAAOA,CACT,CAEA,SAAgBE,EAAe,EAAc,EAAuB,CAClE,GAAI,OAAOF,GAAU,SACnB,MAAU,UAAU,GAAGG,EAAK,mBAAmB,EAEjD,OAAOH,CACT,CAEA,SAAgBI,EAAyB,EAAoC,CAC3E,GACEC,IAAed,EAAAA,iBAAiB,gBAChCc,IAAed,EAAAA,iBAAiB,iBAEhC,MAAU,UACR,kCAAkC,OAAOc,CAAU,EAAE,GACvD,CAEJ,CAEA,SAAgBC,EACd,EACA,EACM,CACN,GAAIC,EAAO,SAAW,EACpB,MAAU,UAAU,GAAGJ,EAAK,kBAAkB,EAEhD,GAAII,EAAO,KAAK,GAASP,GAAU,IAA2B,EAC5D,MAAU,UAAU,GAAGG,EAAK,sBAAsB,CAEtD,CAEA,SAASK,EAAkB,EAA2B,CACpD,IAAMC,EAAQb,EAAoB,KAAKc,CAAQ,EAC/C,GAAI,CAACD,EAAO,MAAO,GACnB,IAAME,EAASF,EAAM,GAMf,CAACG,EAAOC,EAAU,EAAGC,EAAU,IALvBH,EAAO,SAAS,GAAG,EAC7BA,EAAO,MAAM,GAAG,EAChBA,EAAO,QAAU,EACf,CAACA,CAAM,EACP,CAACA,EAAO,MAAM,EAAG,CAAC,EAAGA,EAAO,MAAM,EAAG,CAAC,EAAGA,EAAO,MAAM,EAAG,CAAC,CAAC,EAAA,CACjB,IAAI,MAAM,EAC1D,OACEE,GAAW,IACXC,GAAW,KACVF,EAAQ,IAAOA,IAAU,IAAMC,IAAY,GAAKC,IAAY,EAEjE,CAEA,SAAgBC,EAA4B,CAC1C,YACuD,CACvD,GAAIL,IAAa,IAAA,GAAW,CAC1B,GAAI,OAAOA,GAAa,UAAY,CAACA,EAAS,KAAK,EACjD,MAAU,UAAU,2BAA2B,EAEjD,GACEb,EAA8B,KAAKa,CAAQ,GAC3C,CAACF,EAAkBE,CAAQ,EAE3B,MAAU,UAAU,yBAAyBA,EAAS,GAAG,CAE7D,CACA,OAAOA,IAAa,IAAA,GAAY,CAAC,EAAI,CAAE,UAAS,CAClD,CAEA,SAAgBM,EAAa,EAA0B,EAAoB,CACzE,GAAI,CAAC,OAAO,UAAUC,CAAI,GAAKA,EAAO,GAAKA,EAAO,WAChD,MAAU,UACR,GAAGzB,EAAAA,aAAa0B,CAAQ,EAAE,kCAC5B,CAEJ,CAOA,SAAgBC,EACd,EACA,EACQ,CACR,GAAI,OAAOR,GAAW,UAAY,CAACb,EAAiB,KAAKa,CAAM,EAC7D,MAAU,UACR,GAAGnB,EAAAA,aAAa0B,CAAQ,EAAE,6DAC5B,EAEF,OAAOP,CACT,CAGA,SAAgBS,EAAiB,EAAsB,CACrD,GAAI,OAAOC,GAAS,UAAY,CAAC1B,EAAmB,KAAK0B,CAAI,EAC3D,MAAU,UAAU,+BAA+B,EAErD,OAAOA,CACT,C"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { StringComparison,
|
|
1
|
+
import { StringComparison, FilterOperator } from './operator.cjs';
|
|
2
2
|
import { FilterLiteral, RelativeTimeFilterOptions } from './types.cjs';
|
|
3
3
|
export declare function filterLiteral<T extends FilterLiteral>(value: T, nullable: boolean): T;
|
|
4
4
|
export declare function requiredString(name: string, value: string): string;
|
|
5
5
|
export declare function validateStringComparison(comparison: StringComparison): void;
|
|
6
6
|
export declare function requireNonEmpty(name: string, values: readonly unknown[]): void;
|
|
7
|
-
export declare function validateRelativeTimeOptions({
|
|
8
|
-
timeUnit: TimeUnit;
|
|
9
|
-
};
|
|
7
|
+
export declare function validateRelativeTimeOptions({ timeZone, }: RelativeTimeFilterOptions): RelativeTimeFilterOptions;
|
|
10
8
|
export declare function validateDays(operator: FilterOperator, days: number): void;
|
|
11
9
|
/**
|
|
12
10
|
* Admits the ISO-8601 duration `BEFORE_NOW` and `AFTER_NOW` add to the
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { StringComparison,
|
|
1
|
+
import { StringComparison, FilterOperator } from './operator.js';
|
|
2
2
|
import { FilterLiteral, RelativeTimeFilterOptions } from './types.js';
|
|
3
3
|
export declare function filterLiteral<T extends FilterLiteral>(value: T, nullable: boolean): T;
|
|
4
4
|
export declare function requiredString(name: string, value: string): string;
|
|
5
5
|
export declare function validateStringComparison(comparison: StringComparison): void;
|
|
6
6
|
export declare function requireNonEmpty(name: string, values: readonly unknown[]): void;
|
|
7
|
-
export declare function validateRelativeTimeOptions({
|
|
8
|
-
timeUnit: TimeUnit;
|
|
9
|
-
};
|
|
7
|
+
export declare function validateRelativeTimeOptions({ timeZone, }: RelativeTimeFilterOptions): RelativeTimeFilterOptions;
|
|
10
8
|
export declare function validateDays(operator: FilterOperator, days: number): void;
|
|
11
9
|
/**
|
|
12
10
|
* Admits the ISO-8601 duration `BEFORE_NOW` and `AFTER_NOW` add to the
|
|
@@ -1,56 +1,50 @@
|
|
|
1
|
-
import { StringComparison as e
|
|
2
|
-
import { constantName as
|
|
3
|
-
import { validateDatePattern as r } from "./datePattern.es.js";
|
|
1
|
+
import { StringComparison as e } from "./operator.es.js";
|
|
2
|
+
import { constantName as t } from "../constantName.es.js";
|
|
4
3
|
// src/dsl/filter/validate.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
4
|
+
var n = /^([01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?$/, r = /^(?:UTC|GMT|UT)?[+-](\d{1,2}|\d{4}|\d{6}|\d{2}:\d{2}|\d{2}:\d{2}:\d{2})$/, i = /^(?:UTC|GMT|UT)?[+-]/, a = /^[-+]?P(?=.*[0-9])(?:[-+]?[0-9]+D)?(?:T(?=[-+]?[0-9])(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$/i;
|
|
5
|
+
function o(e, t) {
|
|
7
6
|
if (!(e === null ? t : typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e))) throw TypeError("Filter value must be a JSON scalar.");
|
|
8
7
|
return e;
|
|
9
8
|
}
|
|
10
|
-
function
|
|
9
|
+
function s(e, t) {
|
|
11
10
|
if (typeof t != "string") throw TypeError(`${e} must be a string.`);
|
|
12
11
|
return t;
|
|
13
12
|
}
|
|
14
|
-
function
|
|
13
|
+
function c(t) {
|
|
15
14
|
if (t !== e.CASE_SENSITIVE && t !== e.CASE_INSENSITIVE) throw TypeError(`String comparison is invalid: [${String(t)}].`);
|
|
16
15
|
}
|
|
17
|
-
function
|
|
16
|
+
function l(e, t) {
|
|
18
17
|
if (t.length === 0) throw TypeError(`${e} cannot be empty.`);
|
|
19
18
|
if (t.some((e) => e == null)) throw TypeError(`${e} cannot contain null.`);
|
|
20
19
|
}
|
|
21
|
-
function
|
|
22
|
-
let t =
|
|
20
|
+
function u(e) {
|
|
21
|
+
let t = r.exec(e);
|
|
23
22
|
if (!t) return !1;
|
|
24
|
-
let n = t[1], [
|
|
23
|
+
let n = t[1], [i, a = 0, o = 0] = (n.includes(":") ? n.split(":") : n.length <= 2 ? [n] : [
|
|
25
24
|
n.slice(0, 2),
|
|
26
25
|
n.slice(2, 4),
|
|
27
26
|
n.slice(4, 6)
|
|
28
27
|
]).map(Number);
|
|
29
|
-
return
|
|
28
|
+
return a <= 59 && o <= 59 && (i < 18 || i === 18 && a === 0 && o === 0);
|
|
30
29
|
}
|
|
31
|
-
function
|
|
30
|
+
function d({ timeZone: e }) {
|
|
32
31
|
if (e !== void 0) {
|
|
33
|
-
if (typeof e != "string" || !e.trim()) throw TypeError("
|
|
34
|
-
if (
|
|
32
|
+
if (typeof e != "string" || !e.trim()) throw TypeError("timeZone cannot be blank.");
|
|
33
|
+
if (i.test(e) && !u(e)) throw TypeError(`timeZone is invalid: [${e}].`);
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!Number.isInteger(t) || t < 1 || t > 2147483647) throw TypeError(`${n(e)} days must be a positive JVM Int.`);
|
|
45
|
-
}
|
|
46
|
-
function h(e, t) {
|
|
47
|
-
if (typeof t != "string" || !s.test(t)) throw TypeError(`${n(e)} offset must be an ISO-8601 duration such as PT0S or -PT30M.`);
|
|
48
|
-
return t;
|
|
35
|
+
return e === void 0 ? {} : { timeZone: e };
|
|
36
|
+
}
|
|
37
|
+
function f(e, n) {
|
|
38
|
+
if (!Number.isInteger(n) || n < 1 || n > 2147483647) throw TypeError(`${t(e)} days must be a positive JVM Int.`);
|
|
39
|
+
}
|
|
40
|
+
function p(e, n) {
|
|
41
|
+
if (typeof n != "string" || !a.test(n)) throw TypeError(`${t(e)} offset must be an ISO-8601 duration such as PT0S or -PT30M.`);
|
|
42
|
+
return n;
|
|
49
43
|
}
|
|
50
|
-
function
|
|
51
|
-
if (typeof e != "string" || !
|
|
44
|
+
function m(e) {
|
|
45
|
+
if (typeof e != "string" || !n.test(e)) throw TypeError("BEFORE_TODAY time is invalid.");
|
|
52
46
|
return e;
|
|
53
47
|
}
|
|
54
|
-
export {
|
|
48
|
+
export { o as filterLiteral, p as requireDuration, m as requireLocalTime, l as requireNonEmpty, s as requiredString, f as validateDays, d as validateRelativeTimeOptions, c as validateStringComparison };
|
|
55
49
|
|
|
56
50
|
//# sourceMappingURL=validate.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.es.js","names":["LOCAL_TIME_PATTERN","OFFSET_ZONE_PATTERN","OFFSET_ZONE_CANDIDATE_PATTERN","DURATION_PATTERN","filterLiteral","value","nullable","requiredString","name","validateStringComparison","comparison","StringComparison","requireNonEmpty","values","isValidOffsetZone","match","
|
|
1
|
+
{"version":3,"file":"validate.es.js","names":["LOCAL_TIME_PATTERN","OFFSET_ZONE_PATTERN","OFFSET_ZONE_CANDIDATE_PATTERN","DURATION_PATTERN","filterLiteral","value","nullable","requiredString","name","validateStringComparison","comparison","StringComparison","requireNonEmpty","values","isValidOffsetZone","match","timeZone","offset","hours","minutes","seconds","validateRelativeTimeOptions","validateDays","days","constantName","operator","requireDuration","requireLocalTime","time"],"sources":["../../../src/dsl/filter/validate.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// Internal: not re-exported by filter/index.ts. The argument checks the\n// filter builders share.\nimport { constantName } from '../constantName.js';\nimport { StringComparison, type FilterOperator } from './operator.js';\nimport type { FilterLiteral, RelativeTimeFilterOptions } from './types.js';\n\nconst LOCAL_TIME_PATTERN =\n /^([01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\\.[0-9]{1,9})?)?$/;\nconst OFFSET_ZONE_PATTERN =\n /^(?:UTC|GMT|UT)?[+-](\\d{1,2}|\\d{4}|\\d{6}|\\d{2}:\\d{2}|\\d{2}:\\d{2}:\\d{2})$/;\nconst OFFSET_ZONE_CANDIDATE_PATTERN = /^(?:UTC|GMT|UT)?[+-]/;\n// java.time.Duration.parse: signed days, hours, minutes and seconds (up to\n// nine fraction digits after `.` or `,`), at least one of them, in that order,\n// case-insensitive. Weeks, months and years are not durations.\nconst DURATION_PATTERN =\n /^[-+]?P(?=.*[0-9])(?:[-+]?[0-9]+D)?(?:T(?=[-+]?[0-9])(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$/i;\n\nexport function filterLiteral<T extends FilterLiteral>(\n value: T,\n nullable: boolean,\n): T {\n const valid =\n value === null\n ? nullable\n : typeof value === 'string' ||\n typeof value === 'boolean' ||\n (typeof value === 'number' && Number.isFinite(value));\n if (!valid) {\n throw new TypeError('Filter value must be a JSON scalar.');\n }\n return value;\n}\n\nexport function requiredString(name: string, value: string): string {\n if (typeof value !== 'string') {\n throw new TypeError(`${name} must be a string.`);\n }\n return value;\n}\n\nexport function validateStringComparison(comparison: StringComparison): void {\n if (\n comparison !== StringComparison.CASE_SENSITIVE &&\n comparison !== StringComparison.CASE_INSENSITIVE\n ) {\n throw new TypeError(\n `String comparison is invalid: [${String(comparison)}].`,\n );\n }\n}\n\nexport function requireNonEmpty(\n name: string,\n values: readonly unknown[],\n): void {\n if (values.length === 0) {\n throw new TypeError(`${name} cannot be empty.`);\n }\n if (values.some(value => value === null || value === undefined)) {\n throw new TypeError(`${name} cannot contain null.`);\n }\n}\n\nfunction isValidOffsetZone(timeZone: string): boolean {\n const match = OFFSET_ZONE_PATTERN.exec(timeZone);\n if (!match) return false;\n const offset = match[1];\n const parts = offset.includes(':')\n ? offset.split(':')\n : offset.length <= 2\n ? [offset]\n : [offset.slice(0, 2), offset.slice(2, 4), offset.slice(4, 6)];\n const [hours, minutes = 0, seconds = 0] = parts.map(Number);\n return (\n minutes <= 59 &&\n seconds <= 59 &&\n (hours < 18 || (hours === 18 && minutes === 0 && seconds === 0))\n );\n}\n\nexport function validateRelativeTimeOptions({\n timeZone,\n}: RelativeTimeFilterOptions): RelativeTimeFilterOptions {\n if (timeZone !== undefined) {\n if (typeof timeZone !== 'string' || !timeZone.trim()) {\n throw new TypeError('timeZone cannot be blank.');\n }\n if (\n OFFSET_ZONE_CANDIDATE_PATTERN.test(timeZone) &&\n !isValidOffsetZone(timeZone)\n ) {\n throw new TypeError(`timeZone is invalid: [${timeZone}].`);\n }\n }\n return timeZone === undefined ? {} : { timeZone };\n}\n\nexport function validateDays(operator: FilterOperator, days: number): void {\n if (!Number.isInteger(days) || days < 1 || days > 2_147_483_647) {\n throw new TypeError(\n `${constantName(operator)} days must be a positive JVM Int.`,\n );\n }\n}\n\n/**\n * Admits the ISO-8601 duration `BEFORE_NOW` and `AFTER_NOW` add to the\n * server's now, in the grammar `java.time.Duration.parse` accepts. A value\n * too large for a `Duration` is left to the server.\n */\nexport function requireDuration(\n operator: FilterOperator,\n offset: string,\n): string {\n if (typeof offset !== 'string' || !DURATION_PATTERN.test(offset)) {\n throw new TypeError(\n `${constantName(operator)} offset must be an ISO-8601 duration such as PT0S or -PT30M.`,\n );\n }\n return offset;\n}\n\n/** Admits the 24-hour local time `BEFORE_TODAY` compares against. */\nexport function requireLocalTime(time: string): string {\n if (typeof time !== 'string' || !LOCAL_TIME_PATTERN.test(time)) {\n throw new TypeError('BEFORE_TODAY time is invalid.');\n }\n return time;\n}\n"],"mappings":";;;AAmBA,IAAMA,IACJ,oEACIC,IACJ,4EACIC,IAAgC,wBAIhCC,IACJ;AAEF,SAAgBC,EACd,GACA,GACG;CAOH,IAAI,EALFC,MAAU,OACNC,IACA,OAAOD,KAAU,YACjB,OAAOA,KAAU,aAChB,OAAOA,KAAU,YAAY,OAAO,SAASA,CAAK,IAEvD,MAAU,UAAU,qCAAqC;CAE3D,OAAOA;AACT;AAEA,SAAgBE,EAAe,GAAc,GAAuB;CAClE,IAAI,OAAOF,KAAU,UACnB,MAAU,UAAU,GAAGG,EAAK,mBAAmB;CAEjD,OAAOH;AACT;AAEA,SAAgBI,EAAyB,GAAoC;CAC3E,IACEC,MAAeC,EAAiB,kBAChCD,MAAeC,EAAiB,kBAEhC,MAAU,UACR,kCAAkC,OAAOD,CAAU,EAAE,GACvD;AAEJ;AAEA,SAAgBE,EACd,GACA,GACM;CACN,IAAIC,EAAO,WAAW,GACpB,MAAU,UAAU,GAAGL,EAAK,kBAAkB;CAEhD,IAAIK,EAAO,MAAK,MAASR,KAAU,IAA2B,GAC5D,MAAU,UAAU,GAAGG,EAAK,sBAAsB;AAEtD;AAEA,SAASM,EAAkB,GAA2B;CACpD,IAAMC,IAAQd,EAAoB,KAAKe,CAAQ;CAC/C,IAAI,CAACD,GAAO,OAAO;CACnB,IAAME,IAASF,EAAM,IAMf,CAACG,GAAOC,IAAU,GAAGC,IAAU,MALvBH,EAAO,SAAS,GAAG,IAC7BA,EAAO,MAAM,GAAG,IAChBA,EAAO,UAAU,IACf,CAACA,CAAM,IACP;EAACA,EAAO,MAAM,GAAG,CAAC;EAAGA,EAAO,MAAM,GAAG,CAAC;EAAGA,EAAO,MAAM,GAAG,CAAC;CAAC,EAAA,CACjB,IAAI,MAAM;CAC1D,OACEE,KAAW,MACXC,KAAW,OACVF,IAAQ,MAAOA,MAAU,MAAMC,MAAY,KAAKC,MAAY;AAEjE;AAEA,SAAgBC,EAA4B,EAC1C,eACuD;CACvD,IAAIL,MAAa,KAAA,GAAW;EAC1B,IAAI,OAAOA,KAAa,YAAY,CAACA,EAAS,KAAK,GACjD,MAAU,UAAU,2BAA2B;EAEjD,IACEd,EAA8B,KAAKc,CAAQ,KAC3C,CAACF,EAAkBE,CAAQ,GAE3B,MAAU,UAAU,yBAAyBA,EAAS,GAAG;CAE7D;CACA,OAAOA,MAAa,KAAA,IAAY,CAAC,IAAI,EAAE,YAAS;AAClD;AAEA,SAAgBM,EAAa,GAA0B,GAAoB;CACzE,IAAI,CAAC,OAAO,UAAUC,CAAI,KAAKA,IAAO,KAAKA,IAAO,YAChD,MAAU,UACR,GAAGC,EAAaC,CAAQ,EAAE,kCAC5B;AAEJ;AAOA,SAAgBC,EACd,GACA,GACQ;CACR,IAAI,OAAOT,KAAW,YAAY,CAACd,EAAiB,KAAKc,CAAM,GAC7D,MAAU,UACR,GAAGO,EAAaC,CAAQ,EAAE,6DAC5B;CAEF,OAAOR;AACT;AAGA,SAAgBU,EAAiB,GAAsB;CACrD,IAAI,OAAOC,KAAS,YAAY,CAAC5B,EAAmB,KAAK4B,CAAI,GAC3D,MAAU,UAAU,+BAA+B;CAErD,OAAOA;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=Object.freeze({INVALID_JSON:`invalid-json`,BODY_NOT_OBJECT:`body-not-object`,EMPTY_BODY:`empty-body`,UNKNOWN_PROPERTY:`unknown-property`,UNKNOWN_TYPE:`unknown-type`,UNKNOWN_VALUE:`unknown-value`,INVALID_VALUE:`invalid-value`,INVALID_REQUEST:`invalid-request`,CURSOR_SORT_DUPLICATE:`cursor-sort-duplicate`,CURSOR_SORT_TOO_MANY:`cursor-sort-too-many`,INVALID_CURSOR:`invalid-cursor`,STREAM_NOT_RESUMABLE:`stream-not-resumable`,SIZE_OUT_OF_RANGE:`size-out-of-range`,FILTER_TOO_LARGE:`filter-too-large`,EXPENSIVE_OPERATOR_DISABLED:`expensive-operator-disabled`,COUNT_REQUIRES_FILTER:`count-requires-filter`,RESIDUAL_GROUPS_EXCEEDED:`residual-groups-exceeded`,TOO_MANY_GROUPS:`too-many-groups`,EXPLICIT_ENTRY_REQUIRED:`explicit-entry-required`,REPLAY_TOO_LONG:`replay-too-long`,UNKNOWN_FIELD:`unknown-field`,UNSUPPORTED_CAPABILITY:`unsupported-capability`,ELEMENT_SCOPE_REQUIRED:`element-scope-required`,VALUE_MISMATCH:`value-mismatch`,NOT_COLLECTION:`not-collection`,NOT_SINGLE_STRING:`not-single-string`,MODEL_SEARCH_UNSUPPORTED:`model-search-unsupported`,CURSOR_NOT_ALLOWED:`cursor-not-allowed`,PROTECTED_AGGREGATION:`protected-aggregation`,PROTECTED_COMPARISON:`protected-comparison`,MISSING_KEY_REQUIRES_STRING:`missing-key-requires-string`,ANY_REQUIRES_SINGLE_VALUE:`any-requires-single-value`,INCOMPLETE_PROJECTION:`incomplete-projection`,METRIC_FILTER_SEARCH:`metric-filter-search`,METRIC_FILTER_ELEMENT_MATCH:`metric-filter-element-match`,METRIC_FILTER_ARRAY_FIELD:`metric-filter-array-field`,NOT_PROJECTABLE:`not-projectable`,EVENT_PROJECTION_TYPE_REQUIRED:`event-projection-type-required`,TEMPORAL_REPRESENTATION_REQUIRED:`temporal-representation-required`,
|
|
1
|
+
var e=Object.freeze({INVALID_JSON:`invalid-json`,BODY_NOT_OBJECT:`body-not-object`,EMPTY_BODY:`empty-body`,UNKNOWN_PROPERTY:`unknown-property`,UNKNOWN_TYPE:`unknown-type`,UNKNOWN_VALUE:`unknown-value`,INVALID_VALUE:`invalid-value`,INVALID_REQUEST:`invalid-request`,CURSOR_SORT_DUPLICATE:`cursor-sort-duplicate`,CURSOR_SORT_TOO_MANY:`cursor-sort-too-many`,INVALID_CURSOR:`invalid-cursor`,STREAM_NOT_RESUMABLE:`stream-not-resumable`,SIZE_OUT_OF_RANGE:`size-out-of-range`,FILTER_TOO_LARGE:`filter-too-large`,EXPENSIVE_OPERATOR_DISABLED:`expensive-operator-disabled`,COUNT_REQUIRES_FILTER:`count-requires-filter`,RESIDUAL_GROUPS_EXCEEDED:`residual-groups-exceeded`,TOO_MANY_GROUPS:`too-many-groups`,EXPLICIT_ENTRY_REQUIRED:`explicit-entry-required`,REPLAY_TOO_LONG:`replay-too-long`,UNKNOWN_FIELD:`unknown-field`,UNSUPPORTED_CAPABILITY:`unsupported-capability`,ELEMENT_SCOPE_REQUIRED:`element-scope-required`,VALUE_MISMATCH:`value-mismatch`,NOT_COLLECTION:`not-collection`,NOT_SINGLE_STRING:`not-single-string`,MODEL_SEARCH_UNSUPPORTED:`model-search-unsupported`,CURSOR_NOT_ALLOWED:`cursor-not-allowed`,PROTECTED_AGGREGATION:`protected-aggregation`,PROTECTED_COMPARISON:`protected-comparison`,MISSING_KEY_REQUIRES_STRING:`missing-key-requires-string`,ANY_REQUIRES_SINGLE_VALUE:`any-requires-single-value`,INCOMPLETE_PROJECTION:`incomplete-projection`,METRIC_FILTER_SEARCH:`metric-filter-search`,METRIC_FILTER_ELEMENT_MATCH:`metric-filter-element-match`,METRIC_FILTER_ARRAY_FIELD:`metric-filter-array-field`,NOT_PROJECTABLE:`not-projectable`,EVENT_PROJECTION_TYPE_REQUIRED:`event-projection-type-required`,TEMPORAL_REPRESENTATION_REQUIRED:`temporal-representation-required`,PARALLEL_ARRAY_SORT:`parallel-array-sort`,ARRAY_EQUALITY:`array-equality`,FIRST_LAST_REQUIRES_SINGLE_VALUE:`first-last-requires-single-value`,FIRST_LAST_REQUIRES_ORDER_BY:`first-last-requires-order-by`,TEMPORAL_AGGREGATION_UNSUPPORTED:`temporal-aggregation-unsupported`,SORT_TOO_MANY:`sort-too-many`,SORT_FIELD_DUPLICATE:`sort-field-duplicate`,IDENTITY_UNDEFINED:`identity-undefined`,STORAGE_UNSUPPORTED:`storage-unsupported`,PREVIOUS_UNSHIFTABLE:`previous-unshiftable`});exports.QueryErrorCodes=e;
|
|
2
2
|
//# sourceMappingURL=queryErrorCodes.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryErrorCodes.cjs","names":["QueryErrorCodes"],"sources":["../../src/dsl/queryErrorCodes.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/**\n * The codes the violations of a rejected query carry: which rule the request\n * broke, stable where the human text is not. A query route answers a query it\n * refuses with the problem `wow.query.invalid` (`WowProblemError`), each of\n * whose `violations` names one of these codes and where it applies.\n *\n * Mirrors `QueryErrorCodes` in\n * `api/query-api/src/main/kotlin/me/ahoo/wow/api/query/QueryErrorCodes.kt`.\n * The list is open: Wow adds codes and never renames or reuses one, so a\n * client treats a code it does not know as a generic rejection and shows the\n * violation's message. {@link QueryErrorCode} admits those codes too.\n *\n * A violation's `path` locates it three ways:\n * - decoding the request body: the JSON path of the offending value, such as\n * `filter.state` or `metrics[0]`, or `body` for the body as a whole;\n * - the entry's budget and gates: the part of the request the rule bounds,\n * such as `limit` or `filter`;\n * - admission against the query model: the absolute logical field path, such\n * as `state.items.sku`, or `''` when the rule is about the model rather\n * than one field.\n */\nexport const QueryErrorCodes = Object.freeze({\n /** The body is not valid JSON. */\n INVALID_JSON: 'invalid-json',\n /** The body is JSON but not an object. */\n BODY_NOT_OBJECT: 'body-not-object',\n /** The body is empty. */\n EMPTY_BODY: 'empty-body',\n /** The body has a property the query type does not declare. */\n UNKNOWN_PROPERTY: 'unknown-property',\n /** An `op`, metric or other type discriminator names no known type. */\n UNKNOWN_TYPE: 'unknown-type',\n /** An enum value is not one the server knows. */\n UNKNOWN_VALUE: 'unknown-value',\n /** A value is missing or has the wrong JSON type. */\n INVALID_VALUE: 'invalid-value',\n /** Any other request rule; the message names it. */\n INVALID_REQUEST: 'invalid-request',\n /** A cursor sort names a field twice; `path` is the repeated field. */\n CURSOR_SORT_DUPLICATE: 'cursor-sort-duplicate',\n /** A cursor sort has too many fields once the identity tie-breaker is appended. */\n CURSOR_SORT_TOO_MANY: 'cursor-sort-too-many',\n /**\n * The cursor token was not issued for this model and effective sort, or\n * does not decode; `path` is `cursor`. Start again from the first page.\n */\n INVALID_CURSOR: 'invalid-cursor',\n /**\n * A stream that cannot be resumed, its sort having no keyset in its store,\n * names no `limit`: it would stop at a default and say nothing. Name a\n * `limit`, or sort by fields its store keeps a keyset of; `path` is `limit`.\n */\n STREAM_NOT_RESUMABLE: 'stream-not-resumable',\n /**\n * The entry's budget: a list or aggregation `limit`, a page's index, size,\n * window or offset, or a cursor page's `size` is out of range; `path` names\n * which (`limit`, `pagination.size`, `size`, …).\n */\n SIZE_OUT_OF_RANGE: 'size-out-of-range',\n /**\n * The entry's budget: the filter or `having` has too many nodes or values;\n * `path` is `filter` or `having`.\n */\n FILTER_TOO_LARGE: 'filter-too-large',\n /**\n * The entry does not allow expensive operators, and the query uses one: an\n * operator, an element expansion, a metric sort, an arithmetic or\n * expression group, a date part, a dense fill or FIRST / LAST; `path` names\n * the part (`filter`, `elements`, `sort`, `metrics`, `groupBy`).\n */\n EXPENSIVE_OPERATOR_DISABLED: 'expensive-operator-disabled',\n /**\n * A counting query (count, or a paged query's total) would match every\n * record, which the entry refuses; `path` is `filter`.\n */\n COUNT_REQUIRES_FILTER: 'count-requires-filter',\n /**\n * A `having` or metric sort the storage evaluates after grouping read more\n * groups than the server allows; `path` is `body`. It may end a stream\n * partway through.\n */\n RESIDUAL_GROUPS_EXCEEDED: 'residual-groups-exceeded',\n /**\n * An aggregation that names no sort found more groups than its `limit`;\n * `path` is `limit`. Add a sort for a top-N, or raise the limit.\n */\n TOO_MANY_GROUPS: 'too-many-groups',\n /**\n * An in-process query named no entry where one is required. Never\n * answered over HTTP; listed so the mirror stays complete.\n */\n EXPLICIT_ENTRY_REQUIRED: 'explicit-entry-required',\n /**\n * A state point read (`GET …/{id}/state?version=|at=`, `…/state/trace`): the\n * state asked for is more commits away from the snapshot, or from version 1,\n * than a state read replays. The path is the query parameter.\n */\n REPLAY_TOO_LONG: 'replay-too-long',\n /** The model has no such logical field. */\n UNKNOWN_FIELD: 'unknown-field',\n /** The field does not offer the capability the query uses (sort, range, …). */\n UNSUPPORTED_CAPABILITY: 'unsupported-capability',\n /** The field is an element field and must be queried inside its element scope. */\n ELEMENT_SCOPE_REQUIRED: 'element-scope-required',\n /** A filter value falls outside the field's declared domain. */\n VALUE_MISMATCH: 'value-mismatch',\n /** The field is not a known collection (for example under `isEmpty`). */\n NOT_COLLECTION: 'not-collection',\n /** The field is not a single string. */\n NOT_SINGLE_STRING: 'not-single-string',\n /** The model does not support search. */\n MODEL_SEARCH_UNSUPPORTED: 'model-search-unsupported',\n /** The field cannot be used for a cursor. */\n CURSOR_NOT_ALLOWED: 'cursor-not-allowed',\n /** The field is protected and cannot be aggregated. */\n PROTECTED_AGGREGATION: 'protected-aggregation',\n /**\n * The field is protected and cannot be filtered or sorted: its descriptor\n * says `sensitivity.comparable: false`. A search that names it is refused\n * the same way.\n */\n PROTECTED_COMPARISON: 'protected-comparison',\n /** A terms group's `missingKey` needs a single-valued string field. */\n MISSING_KEY_REQUIRES_STRING: 'missing-key-requires-string',\n /** `ANY` needs a single value. */\n ANY_REQUIRES_SINGLE_VALUE: 'any-requires-single-value',\n /** The storage cannot deliver a complete projection; select fields explicitly. */\n INCOMPLETE_PROJECTION: 'incomplete-projection',\n /** A metric filter uses a search filter. */\n METRIC_FILTER_SEARCH: 'metric-filter-search',\n /** A metric filter uses `ELEMENT_MATCH`. */\n METRIC_FILTER_ELEMENT_MATCH: 'metric-filter-element-match',\n /** A metric filter names an array field; it must be scalar. */\n METRIC_FILTER_ARRAY_FIELD: 'metric-filter-array-field',\n /** The field cannot be projected. */\n NOT_PROJECTABLE: 'not-projectable',\n /** An event projection that keeps payloads must keep their `bodyType`. */\n EVENT_PROJECTION_TYPE_REQUIRED: 'event-projection-type-required',\n /** A relative-time filter needs a field with a known temporal representation. */\n TEMPORAL_REPRESENTATION_REQUIRED: 'temporal-representation-required',\n /** A relative-time filter's zone, pattern or unit conflicts with the field's definition. */\n TEMPORAL_CONFIGURATION_CONFLICT: 'temporal-configuration-conflict',\n /**\n * A sort names two array fields on independent arrays, which the storage\n * cannot order by together; `path` is the second of them. The descriptor\n * lists such fields under a `PARALLEL_ARRAY_SORT` constraint.\n */\n PARALLEL_ARRAY_SORT: 'parallel-array-sort',\n /**\n * An `EQ` or `NE` compares the field to an array, which the storage cannot\n * do: it takes only a scalar operand. The descriptor says so with an\n * `ARRAY_EQUALITY` constraint.\n */\n ARRAY_EQUALITY: 'array-equality',\n /**\n * A `FIRST` or `LAST` metric names a field that may hold several values;\n * it needs a single-valued one (`aggregate.firstLast` in the descriptor).\n */\n FIRST_LAST_REQUIRES_SINGLE_VALUE: 'first-last-requires-single-value',\n /**\n * A `FIRST` or `LAST` metric names no `orderBy` where there is no event\n * time to order by, such as inside an element or on a model whose\n * descriptor has no `analysis.firstLastOrderBy`; `path` is its field.\n */\n FIRST_LAST_REQUIRES_ORDER_BY: 'first-last-requires-order-by',\n /**\n * A date group or date difference names a field that stores neither a\n * date nor an epoch (a formatted string, say), so it cannot be aggregated\n * by time.\n */\n TEMPORAL_AGGREGATION_UNSUPPORTED: 'temporal-aggregation-unsupported',\n /** The sort has more fields than the protocol allows; `path` is `''`. */\n SORT_TOO_MANY: 'sort-too-many',\n /** Two sort fields name the same stored field; `path` is the second. */\n SORT_FIELD_DUPLICATE: 'sort-field-duplicate',\n /**\n * An identity filter or a cursor on a model that defines no record\n * identity; `path` is `''`.\n */\n IDENTITY_UNDEFINED: 'identity-undefined',\n /**\n * The storage does not support the feature the query uses, or its native\n * query language cannot express it (a MongoDB PHRASE search with a quote,\n * say); `path` is the field, or `''`.\n */\n STORAGE_UNSUPPORTED: 'storage-unsupported',\n /**\n * A `PREVIOUS` window steps along a date group whose field the filter\n * conditions where its range cannot be shifted to the earlier period:\n * outside the top-level `AND`, or with a value that is not an instant;\n * `path` is the field.\n */\n PREVIOUS_UNSHIFTABLE: 'previous-unshiftable',\n} as const);\n\n/** One of the codes this package knows; see {@link QueryErrorCodes}. */\nexport type KnownQueryErrorCode =\n (typeof QueryErrorCodes)[keyof typeof QueryErrorCodes];\n\n/**\n * The code of a rejected query: one this package knows, which editors\n * complete, or one a newer server added.\n */\nexport type QueryErrorCode = KnownQueryErrorCode | (string & {});\n\n/**\n * Why the server rejected a query: one violation of its `wow.query.invalid`\n * problem, which rule failed, where, and the server's words.\n */\nexport interface QueryViolation {\n /** Which rule failed; switch on it against {@link QueryErrorCodes}. */\n code: QueryErrorCode;\n /**\n * Where: the JSON path of the offending value for a decoding error\n * (`filter.state`, `metrics[0]`, `body`), the absolute logical field path\n * for an admission error (`state.items.sku`), or `''` when the rule is about\n * the model rather than a field.\n */\n path: string;\n /** The server's words. */\n message: string;\n}\n"],"mappings":"AAkCA,IAAaA,EAAkB,OAAO,OAAO,CAE3C,aAAc,eAEd,gBAAiB,kBAEjB,WAAY,aAEZ,iBAAkB,mBAElB,aAAc,eAEd,cAAe,gBAEf,cAAe,gBAEf,gBAAiB,kBAEjB,sBAAuB,wBAEvB,qBAAsB,uBAKtB,eAAgB,iBAMhB,qBAAsB,uBAMtB,kBAAmB,oBAKnB,iBAAkB,mBAOlB,4BAA6B,8BAK7B,sBAAuB,wBAMvB,yBAA0B,2BAK1B,gBAAiB,kBAKjB,wBAAyB,0BAMzB,gBAAiB,kBAEjB,cAAe,gBAEf,uBAAwB,yBAExB,uBAAwB,yBAExB,eAAgB,iBAEhB,eAAgB,iBAEhB,kBAAmB,oBAEnB,yBAA0B,2BAE1B,mBAAoB,qBAEpB,sBAAuB,wBAMvB,qBAAsB,uBAEtB,4BAA6B,8BAE7B,0BAA2B,4BAE3B,sBAAuB,wBAEvB,qBAAsB,uBAEtB,4BAA6B,8BAE7B,0BAA2B,4BAE3B,gBAAiB,kBAEjB,+BAAgC,iCAEhC,iCAAkC,mCAElC,gCAAiC,kCAMjC,oBAAqB,sBAMrB,eAAgB,iBAKhB,iCAAkC,mCAMlC,6BAA8B,+BAM9B,iCAAkC,mCAElC,cAAe,gBAEf,qBAAsB,uBAKtB,mBAAoB,qBAMpB,oBAAqB,sBAOrB,qBAAsB,sBACxB,CAAU,E"}
|
|
1
|
+
{"version":3,"file":"queryErrorCodes.cjs","names":["QueryErrorCodes"],"sources":["../../src/dsl/queryErrorCodes.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/**\n * The codes the violations of a rejected query carry: which rule the request\n * broke, stable where the human text is not. A query route answers a query it\n * refuses with the problem `wow.query.invalid` (`WowProblemError`), each of\n * whose `violations` names one of these codes and where it applies.\n *\n * Mirrors `QueryErrorCodes` in\n * `api/query-api/src/main/kotlin/me/ahoo/wow/api/query/QueryErrorCodes.kt`.\n * The list is open: Wow adds codes and never renames or reuses one, so a\n * client treats a code it does not know as a generic rejection and shows the\n * violation's message. {@link QueryErrorCode} admits those codes too.\n *\n * A violation's `path` locates it three ways:\n * - decoding the request body: the JSON path of the offending value, such as\n * `filter.state` or `metrics[0]`, or `body` for the body as a whole;\n * - the entry's budget and gates: the part of the request the rule bounds,\n * such as `limit` or `filter`;\n * - admission against the query model: the absolute logical field path, such\n * as `state.items.sku`, or `''` when the rule is about the model rather\n * than one field.\n */\nexport const QueryErrorCodes = Object.freeze({\n /** The body is not valid JSON. */\n INVALID_JSON: 'invalid-json',\n /** The body is JSON but not an object. */\n BODY_NOT_OBJECT: 'body-not-object',\n /** The body is empty. */\n EMPTY_BODY: 'empty-body',\n /** The body has a property the query type does not declare. */\n UNKNOWN_PROPERTY: 'unknown-property',\n /** An `op`, metric or other type discriminator names no known type. */\n UNKNOWN_TYPE: 'unknown-type',\n /** An enum value is not one the server knows. */\n UNKNOWN_VALUE: 'unknown-value',\n /** A value is missing or has the wrong JSON type. */\n INVALID_VALUE: 'invalid-value',\n /** Any other request rule; the message names it. */\n INVALID_REQUEST: 'invalid-request',\n /** A cursor sort names a field twice; `path` is the repeated field. */\n CURSOR_SORT_DUPLICATE: 'cursor-sort-duplicate',\n /** A cursor sort has too many fields once the identity tie-breaker is appended. */\n CURSOR_SORT_TOO_MANY: 'cursor-sort-too-many',\n /**\n * The cursor token was not issued for this model and effective sort, or\n * does not decode; `path` is `cursor`. Start again from the first page.\n */\n INVALID_CURSOR: 'invalid-cursor',\n /**\n * A stream that cannot be resumed, its sort having no keyset in its store,\n * names no `limit`: it would stop at a default and say nothing. Name a\n * `limit`, or sort by fields its store keeps a keyset of; `path` is `limit`.\n */\n STREAM_NOT_RESUMABLE: 'stream-not-resumable',\n /**\n * The entry's budget: a list or aggregation `limit`, a page's index, size,\n * window or offset, or a cursor page's `size` is out of range; `path` names\n * which (`limit`, `pagination.size`, `size`, …).\n */\n SIZE_OUT_OF_RANGE: 'size-out-of-range',\n /**\n * The entry's budget: the filter or `having` has too many nodes or values;\n * `path` is `filter` or `having`.\n */\n FILTER_TOO_LARGE: 'filter-too-large',\n /**\n * The entry does not allow expensive operators, and the query uses one: an\n * operator, an element expansion, a metric sort, an arithmetic or\n * expression group, a date part, a dense fill or FIRST / LAST; `path` names\n * the part (`filter`, `elements`, `sort`, `metrics`, `groupBy`).\n */\n EXPENSIVE_OPERATOR_DISABLED: 'expensive-operator-disabled',\n /**\n * A counting query (count, or a paged query's total) would match every\n * record, which the entry refuses; `path` is `filter`.\n */\n COUNT_REQUIRES_FILTER: 'count-requires-filter',\n /**\n * A `having` or metric sort the storage evaluates after grouping read more\n * groups than the server allows; `path` is `body`. It may end a stream\n * partway through.\n */\n RESIDUAL_GROUPS_EXCEEDED: 'residual-groups-exceeded',\n /**\n * An aggregation that names no sort found more groups than its `limit`;\n * `path` is `limit`. Add a sort for a top-N, or raise the limit.\n */\n TOO_MANY_GROUPS: 'too-many-groups',\n /**\n * An in-process query named no entry where one is required. Never\n * answered over HTTP; listed so the mirror stays complete.\n */\n EXPLICIT_ENTRY_REQUIRED: 'explicit-entry-required',\n /**\n * A state point read (`GET …/{id}/state?version=|at=`, `…/state/trace`): the\n * state asked for is more commits away from the snapshot, or from version 1,\n * than a state read replays. The path is the query parameter.\n */\n REPLAY_TOO_LONG: 'replay-too-long',\n /** The model has no such logical field. */\n UNKNOWN_FIELD: 'unknown-field',\n /** The field does not offer the capability the query uses (sort, range, …). */\n UNSUPPORTED_CAPABILITY: 'unsupported-capability',\n /** The field is an element field and must be queried inside its element scope. */\n ELEMENT_SCOPE_REQUIRED: 'element-scope-required',\n /** A filter value falls outside the field's declared domain. */\n VALUE_MISMATCH: 'value-mismatch',\n /** The field is not a known collection (for example under `isEmpty`). */\n NOT_COLLECTION: 'not-collection',\n /** The field is not a single string. */\n NOT_SINGLE_STRING: 'not-single-string',\n /** The model does not support search. */\n MODEL_SEARCH_UNSUPPORTED: 'model-search-unsupported',\n /** The field cannot be used for a cursor. */\n CURSOR_NOT_ALLOWED: 'cursor-not-allowed',\n /** The field is protected and cannot be aggregated. */\n PROTECTED_AGGREGATION: 'protected-aggregation',\n /**\n * The field is protected and cannot be filtered or sorted: its descriptor\n * says `sensitivity.comparable: false`. A search that names it is refused\n * the same way.\n */\n PROTECTED_COMPARISON: 'protected-comparison',\n /** A terms group's `missingKey` needs a single-valued string field. */\n MISSING_KEY_REQUIRES_STRING: 'missing-key-requires-string',\n /** `ANY` needs a single value. */\n ANY_REQUIRES_SINGLE_VALUE: 'any-requires-single-value',\n /** The storage cannot deliver a complete projection; select fields explicitly. */\n INCOMPLETE_PROJECTION: 'incomplete-projection',\n /** A metric filter uses a search filter. */\n METRIC_FILTER_SEARCH: 'metric-filter-search',\n /** A metric filter uses `ELEMENT_MATCH`. */\n METRIC_FILTER_ELEMENT_MATCH: 'metric-filter-element-match',\n /** A metric filter names an array field; it must be scalar. */\n METRIC_FILTER_ARRAY_FIELD: 'metric-filter-array-field',\n /** The field cannot be projected. */\n NOT_PROJECTABLE: 'not-projectable',\n /** An event projection that keeps payloads must keep their `bodyType`. */\n EVENT_PROJECTION_TYPE_REQUIRED: 'event-projection-type-required',\n /** A relative-time filter needs a field with a known temporal representation. */\n TEMPORAL_REPRESENTATION_REQUIRED: 'temporal-representation-required',\n /**\n * A sort names two array fields on independent arrays, which the storage\n * cannot order by together; `path` is the second of them. The descriptor\n * lists such fields under a `PARALLEL_ARRAY_SORT` constraint.\n */\n PARALLEL_ARRAY_SORT: 'parallel-array-sort',\n /**\n * An `EQ` or `NE` compares the field to an array, which the storage cannot\n * do: it takes only a scalar operand. The descriptor says so with an\n * `ARRAY_EQUALITY` constraint.\n */\n ARRAY_EQUALITY: 'array-equality',\n /**\n * A `FIRST` or `LAST` metric names a field that may hold several values;\n * it needs a single-valued one (`aggregate.firstLast` in the descriptor).\n */\n FIRST_LAST_REQUIRES_SINGLE_VALUE: 'first-last-requires-single-value',\n /**\n * A `FIRST` or `LAST` metric names no `orderBy` where there is no event\n * time to order by, such as inside an element or on a model whose\n * descriptor has no `analysis.firstLastOrderBy`; `path` is its field.\n */\n FIRST_LAST_REQUIRES_ORDER_BY: 'first-last-requires-order-by',\n /**\n * A date group or date difference names a field that stores neither a\n * date nor an epoch (a formatted string, say), so it cannot be aggregated\n * by time.\n */\n TEMPORAL_AGGREGATION_UNSUPPORTED: 'temporal-aggregation-unsupported',\n /** The sort has more fields than the protocol allows; `path` is `''`. */\n SORT_TOO_MANY: 'sort-too-many',\n /** Two sort fields name the same stored field; `path` is the second. */\n SORT_FIELD_DUPLICATE: 'sort-field-duplicate',\n /**\n * An identity filter or a cursor on a model that defines no record\n * identity; `path` is `''`.\n */\n IDENTITY_UNDEFINED: 'identity-undefined',\n /**\n * The storage does not support the feature the query uses, or its native\n * query language cannot express it (a MongoDB PHRASE search with a quote,\n * say); `path` is the field, or `''`.\n */\n STORAGE_UNSUPPORTED: 'storage-unsupported',\n /**\n * A `PREVIOUS` window steps along a date group whose field the filter\n * conditions where its range cannot be shifted to the earlier period:\n * outside the top-level `AND`, or with a value that is not an instant;\n * `path` is the field.\n */\n PREVIOUS_UNSHIFTABLE: 'previous-unshiftable',\n} as const);\n\n/** One of the codes this package knows; see {@link QueryErrorCodes}. */\nexport type KnownQueryErrorCode =\n (typeof QueryErrorCodes)[keyof typeof QueryErrorCodes];\n\n/**\n * The code of a rejected query: one this package knows, which editors\n * complete, or one a newer server added.\n */\nexport type QueryErrorCode = KnownQueryErrorCode | (string & {});\n\n/**\n * Why the server rejected a query: one violation of its `wow.query.invalid`\n * problem, which rule failed, where, and the server's words.\n */\nexport interface QueryViolation {\n /** Which rule failed; switch on it against {@link QueryErrorCodes}. */\n code: QueryErrorCode;\n /**\n * Where: the JSON path of the offending value for a decoding error\n * (`filter.state`, `metrics[0]`, `body`), the absolute logical field path\n * for an admission error (`state.items.sku`), or `''` when the rule is about\n * the model rather than a field.\n */\n path: string;\n /** The server's words. */\n message: string;\n}\n"],"mappings":"AAkCA,IAAaA,EAAkB,OAAO,OAAO,CAE3C,aAAc,eAEd,gBAAiB,kBAEjB,WAAY,aAEZ,iBAAkB,mBAElB,aAAc,eAEd,cAAe,gBAEf,cAAe,gBAEf,gBAAiB,kBAEjB,sBAAuB,wBAEvB,qBAAsB,uBAKtB,eAAgB,iBAMhB,qBAAsB,uBAMtB,kBAAmB,oBAKnB,iBAAkB,mBAOlB,4BAA6B,8BAK7B,sBAAuB,wBAMvB,yBAA0B,2BAK1B,gBAAiB,kBAKjB,wBAAyB,0BAMzB,gBAAiB,kBAEjB,cAAe,gBAEf,uBAAwB,yBAExB,uBAAwB,yBAExB,eAAgB,iBAEhB,eAAgB,iBAEhB,kBAAmB,oBAEnB,yBAA0B,2BAE1B,mBAAoB,qBAEpB,sBAAuB,wBAMvB,qBAAsB,uBAEtB,4BAA6B,8BAE7B,0BAA2B,4BAE3B,sBAAuB,wBAEvB,qBAAsB,uBAEtB,4BAA6B,8BAE7B,0BAA2B,4BAE3B,gBAAiB,kBAEjB,+BAAgC,iCAEhC,iCAAkC,mCAMlC,oBAAqB,sBAMrB,eAAgB,iBAKhB,iCAAkC,mCAMlC,6BAA8B,+BAM9B,iCAAkC,mCAElC,cAAe,gBAEf,qBAAsB,uBAKtB,mBAAoB,qBAMpB,oBAAqB,sBAOrB,qBAAsB,sBACxB,CAAU,E"}
|
|
@@ -138,8 +138,6 @@ export declare const QueryErrorCodes: Readonly<{
|
|
|
138
138
|
readonly EVENT_PROJECTION_TYPE_REQUIRED: "event-projection-type-required";
|
|
139
139
|
/** A relative-time filter needs a field with a known temporal representation. */
|
|
140
140
|
readonly TEMPORAL_REPRESENTATION_REQUIRED: "temporal-representation-required";
|
|
141
|
-
/** A relative-time filter's zone, pattern or unit conflicts with the field's definition. */
|
|
142
|
-
readonly TEMPORAL_CONFIGURATION_CONFLICT: "temporal-configuration-conflict";
|
|
143
141
|
/**
|
|
144
142
|
* A sort names two array fields on independent arrays, which the storage
|
|
145
143
|
* cannot order by together; `path` is the second of them. The descriptor
|
|
@@ -138,8 +138,6 @@ export declare const QueryErrorCodes: Readonly<{
|
|
|
138
138
|
readonly EVENT_PROJECTION_TYPE_REQUIRED: "event-projection-type-required";
|
|
139
139
|
/** A relative-time filter needs a field with a known temporal representation. */
|
|
140
140
|
readonly TEMPORAL_REPRESENTATION_REQUIRED: "temporal-representation-required";
|
|
141
|
-
/** A relative-time filter's zone, pattern or unit conflicts with the field's definition. */
|
|
142
|
-
readonly TEMPORAL_CONFIGURATION_CONFLICT: "temporal-configuration-conflict";
|
|
143
141
|
/**
|
|
144
142
|
* A sort names two array fields on independent arrays, which the storage
|
|
145
143
|
* cannot order by together; `path` is the second of them. The descriptor
|
|
@@ -39,7 +39,6 @@ var e = Object.freeze({
|
|
|
39
39
|
NOT_PROJECTABLE: "not-projectable",
|
|
40
40
|
EVENT_PROJECTION_TYPE_REQUIRED: "event-projection-type-required",
|
|
41
41
|
TEMPORAL_REPRESENTATION_REQUIRED: "temporal-representation-required",
|
|
42
|
-
TEMPORAL_CONFIGURATION_CONFLICT: "temporal-configuration-conflict",
|
|
43
42
|
PARALLEL_ARRAY_SORT: "parallel-array-sort",
|
|
44
43
|
ARRAY_EQUALITY: "array-equality",
|
|
45
44
|
FIRST_LAST_REQUIRES_SINGLE_VALUE: "first-last-requires-single-value",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryErrorCodes.es.js","names":["QueryErrorCodes"],"sources":["../../src/dsl/queryErrorCodes.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/**\n * The codes the violations of a rejected query carry: which rule the request\n * broke, stable where the human text is not. A query route answers a query it\n * refuses with the problem `wow.query.invalid` (`WowProblemError`), each of\n * whose `violations` names one of these codes and where it applies.\n *\n * Mirrors `QueryErrorCodes` in\n * `api/query-api/src/main/kotlin/me/ahoo/wow/api/query/QueryErrorCodes.kt`.\n * The list is open: Wow adds codes and never renames or reuses one, so a\n * client treats a code it does not know as a generic rejection and shows the\n * violation's message. {@link QueryErrorCode} admits those codes too.\n *\n * A violation's `path` locates it three ways:\n * - decoding the request body: the JSON path of the offending value, such as\n * `filter.state` or `metrics[0]`, or `body` for the body as a whole;\n * - the entry's budget and gates: the part of the request the rule bounds,\n * such as `limit` or `filter`;\n * - admission against the query model: the absolute logical field path, such\n * as `state.items.sku`, or `''` when the rule is about the model rather\n * than one field.\n */\nexport const QueryErrorCodes = Object.freeze({\n /** The body is not valid JSON. */\n INVALID_JSON: 'invalid-json',\n /** The body is JSON but not an object. */\n BODY_NOT_OBJECT: 'body-not-object',\n /** The body is empty. */\n EMPTY_BODY: 'empty-body',\n /** The body has a property the query type does not declare. */\n UNKNOWN_PROPERTY: 'unknown-property',\n /** An `op`, metric or other type discriminator names no known type. */\n UNKNOWN_TYPE: 'unknown-type',\n /** An enum value is not one the server knows. */\n UNKNOWN_VALUE: 'unknown-value',\n /** A value is missing or has the wrong JSON type. */\n INVALID_VALUE: 'invalid-value',\n /** Any other request rule; the message names it. */\n INVALID_REQUEST: 'invalid-request',\n /** A cursor sort names a field twice; `path` is the repeated field. */\n CURSOR_SORT_DUPLICATE: 'cursor-sort-duplicate',\n /** A cursor sort has too many fields once the identity tie-breaker is appended. */\n CURSOR_SORT_TOO_MANY: 'cursor-sort-too-many',\n /**\n * The cursor token was not issued for this model and effective sort, or\n * does not decode; `path` is `cursor`. Start again from the first page.\n */\n INVALID_CURSOR: 'invalid-cursor',\n /**\n * A stream that cannot be resumed, its sort having no keyset in its store,\n * names no `limit`: it would stop at a default and say nothing. Name a\n * `limit`, or sort by fields its store keeps a keyset of; `path` is `limit`.\n */\n STREAM_NOT_RESUMABLE: 'stream-not-resumable',\n /**\n * The entry's budget: a list or aggregation `limit`, a page's index, size,\n * window or offset, or a cursor page's `size` is out of range; `path` names\n * which (`limit`, `pagination.size`, `size`, …).\n */\n SIZE_OUT_OF_RANGE: 'size-out-of-range',\n /**\n * The entry's budget: the filter or `having` has too many nodes or values;\n * `path` is `filter` or `having`.\n */\n FILTER_TOO_LARGE: 'filter-too-large',\n /**\n * The entry does not allow expensive operators, and the query uses one: an\n * operator, an element expansion, a metric sort, an arithmetic or\n * expression group, a date part, a dense fill or FIRST / LAST; `path` names\n * the part (`filter`, `elements`, `sort`, `metrics`, `groupBy`).\n */\n EXPENSIVE_OPERATOR_DISABLED: 'expensive-operator-disabled',\n /**\n * A counting query (count, or a paged query's total) would match every\n * record, which the entry refuses; `path` is `filter`.\n */\n COUNT_REQUIRES_FILTER: 'count-requires-filter',\n /**\n * A `having` or metric sort the storage evaluates after grouping read more\n * groups than the server allows; `path` is `body`. It may end a stream\n * partway through.\n */\n RESIDUAL_GROUPS_EXCEEDED: 'residual-groups-exceeded',\n /**\n * An aggregation that names no sort found more groups than its `limit`;\n * `path` is `limit`. Add a sort for a top-N, or raise the limit.\n */\n TOO_MANY_GROUPS: 'too-many-groups',\n /**\n * An in-process query named no entry where one is required. Never\n * answered over HTTP; listed so the mirror stays complete.\n */\n EXPLICIT_ENTRY_REQUIRED: 'explicit-entry-required',\n /**\n * A state point read (`GET …/{id}/state?version=|at=`, `…/state/trace`): the\n * state asked for is more commits away from the snapshot, or from version 1,\n * than a state read replays. The path is the query parameter.\n */\n REPLAY_TOO_LONG: 'replay-too-long',\n /** The model has no such logical field. */\n UNKNOWN_FIELD: 'unknown-field',\n /** The field does not offer the capability the query uses (sort, range, …). */\n UNSUPPORTED_CAPABILITY: 'unsupported-capability',\n /** The field is an element field and must be queried inside its element scope. */\n ELEMENT_SCOPE_REQUIRED: 'element-scope-required',\n /** A filter value falls outside the field's declared domain. */\n VALUE_MISMATCH: 'value-mismatch',\n /** The field is not a known collection (for example under `isEmpty`). */\n NOT_COLLECTION: 'not-collection',\n /** The field is not a single string. */\n NOT_SINGLE_STRING: 'not-single-string',\n /** The model does not support search. */\n MODEL_SEARCH_UNSUPPORTED: 'model-search-unsupported',\n /** The field cannot be used for a cursor. */\n CURSOR_NOT_ALLOWED: 'cursor-not-allowed',\n /** The field is protected and cannot be aggregated. */\n PROTECTED_AGGREGATION: 'protected-aggregation',\n /**\n * The field is protected and cannot be filtered or sorted: its descriptor\n * says `sensitivity.comparable: false`. A search that names it is refused\n * the same way.\n */\n PROTECTED_COMPARISON: 'protected-comparison',\n /** A terms group's `missingKey` needs a single-valued string field. */\n MISSING_KEY_REQUIRES_STRING: 'missing-key-requires-string',\n /** `ANY` needs a single value. */\n ANY_REQUIRES_SINGLE_VALUE: 'any-requires-single-value',\n /** The storage cannot deliver a complete projection; select fields explicitly. */\n INCOMPLETE_PROJECTION: 'incomplete-projection',\n /** A metric filter uses a search filter. */\n METRIC_FILTER_SEARCH: 'metric-filter-search',\n /** A metric filter uses `ELEMENT_MATCH`. */\n METRIC_FILTER_ELEMENT_MATCH: 'metric-filter-element-match',\n /** A metric filter names an array field; it must be scalar. */\n METRIC_FILTER_ARRAY_FIELD: 'metric-filter-array-field',\n /** The field cannot be projected. */\n NOT_PROJECTABLE: 'not-projectable',\n /** An event projection that keeps payloads must keep their `bodyType`. */\n EVENT_PROJECTION_TYPE_REQUIRED: 'event-projection-type-required',\n /** A relative-time filter needs a field with a known temporal representation. */\n TEMPORAL_REPRESENTATION_REQUIRED: 'temporal-representation-required',\n /** A relative-time filter's zone, pattern or unit conflicts with the field's definition. */\n TEMPORAL_CONFIGURATION_CONFLICT: 'temporal-configuration-conflict',\n /**\n * A sort names two array fields on independent arrays, which the storage\n * cannot order by together; `path` is the second of them. The descriptor\n * lists such fields under a `PARALLEL_ARRAY_SORT` constraint.\n */\n PARALLEL_ARRAY_SORT: 'parallel-array-sort',\n /**\n * An `EQ` or `NE` compares the field to an array, which the storage cannot\n * do: it takes only a scalar operand. The descriptor says so with an\n * `ARRAY_EQUALITY` constraint.\n */\n ARRAY_EQUALITY: 'array-equality',\n /**\n * A `FIRST` or `LAST` metric names a field that may hold several values;\n * it needs a single-valued one (`aggregate.firstLast` in the descriptor).\n */\n FIRST_LAST_REQUIRES_SINGLE_VALUE: 'first-last-requires-single-value',\n /**\n * A `FIRST` or `LAST` metric names no `orderBy` where there is no event\n * time to order by, such as inside an element or on a model whose\n * descriptor has no `analysis.firstLastOrderBy`; `path` is its field.\n */\n FIRST_LAST_REQUIRES_ORDER_BY: 'first-last-requires-order-by',\n /**\n * A date group or date difference names a field that stores neither a\n * date nor an epoch (a formatted string, say), so it cannot be aggregated\n * by time.\n */\n TEMPORAL_AGGREGATION_UNSUPPORTED: 'temporal-aggregation-unsupported',\n /** The sort has more fields than the protocol allows; `path` is `''`. */\n SORT_TOO_MANY: 'sort-too-many',\n /** Two sort fields name the same stored field; `path` is the second. */\n SORT_FIELD_DUPLICATE: 'sort-field-duplicate',\n /**\n * An identity filter or a cursor on a model that defines no record\n * identity; `path` is `''`.\n */\n IDENTITY_UNDEFINED: 'identity-undefined',\n /**\n * The storage does not support the feature the query uses, or its native\n * query language cannot express it (a MongoDB PHRASE search with a quote,\n * say); `path` is the field, or `''`.\n */\n STORAGE_UNSUPPORTED: 'storage-unsupported',\n /**\n * A `PREVIOUS` window steps along a date group whose field the filter\n * conditions where its range cannot be shifted to the earlier period:\n * outside the top-level `AND`, or with a value that is not an instant;\n * `path` is the field.\n */\n PREVIOUS_UNSHIFTABLE: 'previous-unshiftable',\n} as const);\n\n/** One of the codes this package knows; see {@link QueryErrorCodes}. */\nexport type KnownQueryErrorCode =\n (typeof QueryErrorCodes)[keyof typeof QueryErrorCodes];\n\n/**\n * The code of a rejected query: one this package knows, which editors\n * complete, or one a newer server added.\n */\nexport type QueryErrorCode = KnownQueryErrorCode | (string & {});\n\n/**\n * Why the server rejected a query: one violation of its `wow.query.invalid`\n * problem, which rule failed, where, and the server's words.\n */\nexport interface QueryViolation {\n /** Which rule failed; switch on it against {@link QueryErrorCodes}. */\n code: QueryErrorCode;\n /**\n * Where: the JSON path of the offending value for a decoding error\n * (`filter.state`, `metrics[0]`, `body`), the absolute logical field path\n * for an admission error (`state.items.sku`), or `''` when the rule is about\n * the model rather than a field.\n */\n path: string;\n /** The server's words. */\n message: string;\n}\n"],"mappings":";AAkCA,IAAaA,IAAkB,OAAO,OAAO;CAE3C,cAAc;CAEd,iBAAiB;CAEjB,YAAY;CAEZ,kBAAkB;CAElB,cAAc;CAEd,eAAe;CAEf,eAAe;CAEf,iBAAiB;CAEjB,uBAAuB;CAEvB,sBAAsB;CAKtB,gBAAgB;CAMhB,sBAAsB;CAMtB,mBAAmB;CAKnB,kBAAkB;CAOlB,6BAA6B;CAK7B,uBAAuB;CAMvB,0BAA0B;CAK1B,iBAAiB;CAKjB,yBAAyB;CAMzB,iBAAiB;CAEjB,eAAe;CAEf,wBAAwB;CAExB,wBAAwB;CAExB,gBAAgB;CAEhB,gBAAgB;CAEhB,mBAAmB;CAEnB,0BAA0B;CAE1B,oBAAoB;CAEpB,uBAAuB;CAMvB,sBAAsB;CAEtB,6BAA6B;CAE7B,2BAA2B;CAE3B,uBAAuB;CAEvB,sBAAsB;CAEtB,6BAA6B;CAE7B,2BAA2B;CAE3B,iBAAiB;CAEjB,gCAAgC;CAEhC,kCAAkC;CAElC,iCAAiC;CAMjC,qBAAqB;CAMrB,gBAAgB;CAKhB,kCAAkC;CAMlC,8BAA8B;CAM9B,kCAAkC;CAElC,eAAe;CAEf,sBAAsB;CAKtB,oBAAoB;CAMpB,qBAAqB;CAOrB,sBAAsB;AACxB,CAAU"}
|
|
1
|
+
{"version":3,"file":"queryErrorCodes.es.js","names":["QueryErrorCodes"],"sources":["../../src/dsl/queryErrorCodes.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/**\n * The codes the violations of a rejected query carry: which rule the request\n * broke, stable where the human text is not. A query route answers a query it\n * refuses with the problem `wow.query.invalid` (`WowProblemError`), each of\n * whose `violations` names one of these codes and where it applies.\n *\n * Mirrors `QueryErrorCodes` in\n * `api/query-api/src/main/kotlin/me/ahoo/wow/api/query/QueryErrorCodes.kt`.\n * The list is open: Wow adds codes and never renames or reuses one, so a\n * client treats a code it does not know as a generic rejection and shows the\n * violation's message. {@link QueryErrorCode} admits those codes too.\n *\n * A violation's `path` locates it three ways:\n * - decoding the request body: the JSON path of the offending value, such as\n * `filter.state` or `metrics[0]`, or `body` for the body as a whole;\n * - the entry's budget and gates: the part of the request the rule bounds,\n * such as `limit` or `filter`;\n * - admission against the query model: the absolute logical field path, such\n * as `state.items.sku`, or `''` when the rule is about the model rather\n * than one field.\n */\nexport const QueryErrorCodes = Object.freeze({\n /** The body is not valid JSON. */\n INVALID_JSON: 'invalid-json',\n /** The body is JSON but not an object. */\n BODY_NOT_OBJECT: 'body-not-object',\n /** The body is empty. */\n EMPTY_BODY: 'empty-body',\n /** The body has a property the query type does not declare. */\n UNKNOWN_PROPERTY: 'unknown-property',\n /** An `op`, metric or other type discriminator names no known type. */\n UNKNOWN_TYPE: 'unknown-type',\n /** An enum value is not one the server knows. */\n UNKNOWN_VALUE: 'unknown-value',\n /** A value is missing or has the wrong JSON type. */\n INVALID_VALUE: 'invalid-value',\n /** Any other request rule; the message names it. */\n INVALID_REQUEST: 'invalid-request',\n /** A cursor sort names a field twice; `path` is the repeated field. */\n CURSOR_SORT_DUPLICATE: 'cursor-sort-duplicate',\n /** A cursor sort has too many fields once the identity tie-breaker is appended. */\n CURSOR_SORT_TOO_MANY: 'cursor-sort-too-many',\n /**\n * The cursor token was not issued for this model and effective sort, or\n * does not decode; `path` is `cursor`. Start again from the first page.\n */\n INVALID_CURSOR: 'invalid-cursor',\n /**\n * A stream that cannot be resumed, its sort having no keyset in its store,\n * names no `limit`: it would stop at a default and say nothing. Name a\n * `limit`, or sort by fields its store keeps a keyset of; `path` is `limit`.\n */\n STREAM_NOT_RESUMABLE: 'stream-not-resumable',\n /**\n * The entry's budget: a list or aggregation `limit`, a page's index, size,\n * window or offset, or a cursor page's `size` is out of range; `path` names\n * which (`limit`, `pagination.size`, `size`, …).\n */\n SIZE_OUT_OF_RANGE: 'size-out-of-range',\n /**\n * The entry's budget: the filter or `having` has too many nodes or values;\n * `path` is `filter` or `having`.\n */\n FILTER_TOO_LARGE: 'filter-too-large',\n /**\n * The entry does not allow expensive operators, and the query uses one: an\n * operator, an element expansion, a metric sort, an arithmetic or\n * expression group, a date part, a dense fill or FIRST / LAST; `path` names\n * the part (`filter`, `elements`, `sort`, `metrics`, `groupBy`).\n */\n EXPENSIVE_OPERATOR_DISABLED: 'expensive-operator-disabled',\n /**\n * A counting query (count, or a paged query's total) would match every\n * record, which the entry refuses; `path` is `filter`.\n */\n COUNT_REQUIRES_FILTER: 'count-requires-filter',\n /**\n * A `having` or metric sort the storage evaluates after grouping read more\n * groups than the server allows; `path` is `body`. It may end a stream\n * partway through.\n */\n RESIDUAL_GROUPS_EXCEEDED: 'residual-groups-exceeded',\n /**\n * An aggregation that names no sort found more groups than its `limit`;\n * `path` is `limit`. Add a sort for a top-N, or raise the limit.\n */\n TOO_MANY_GROUPS: 'too-many-groups',\n /**\n * An in-process query named no entry where one is required. Never\n * answered over HTTP; listed so the mirror stays complete.\n */\n EXPLICIT_ENTRY_REQUIRED: 'explicit-entry-required',\n /**\n * A state point read (`GET …/{id}/state?version=|at=`, `…/state/trace`): the\n * state asked for is more commits away from the snapshot, or from version 1,\n * than a state read replays. The path is the query parameter.\n */\n REPLAY_TOO_LONG: 'replay-too-long',\n /** The model has no such logical field. */\n UNKNOWN_FIELD: 'unknown-field',\n /** The field does not offer the capability the query uses (sort, range, …). */\n UNSUPPORTED_CAPABILITY: 'unsupported-capability',\n /** The field is an element field and must be queried inside its element scope. */\n ELEMENT_SCOPE_REQUIRED: 'element-scope-required',\n /** A filter value falls outside the field's declared domain. */\n VALUE_MISMATCH: 'value-mismatch',\n /** The field is not a known collection (for example under `isEmpty`). */\n NOT_COLLECTION: 'not-collection',\n /** The field is not a single string. */\n NOT_SINGLE_STRING: 'not-single-string',\n /** The model does not support search. */\n MODEL_SEARCH_UNSUPPORTED: 'model-search-unsupported',\n /** The field cannot be used for a cursor. */\n CURSOR_NOT_ALLOWED: 'cursor-not-allowed',\n /** The field is protected and cannot be aggregated. */\n PROTECTED_AGGREGATION: 'protected-aggregation',\n /**\n * The field is protected and cannot be filtered or sorted: its descriptor\n * says `sensitivity.comparable: false`. A search that names it is refused\n * the same way.\n */\n PROTECTED_COMPARISON: 'protected-comparison',\n /** A terms group's `missingKey` needs a single-valued string field. */\n MISSING_KEY_REQUIRES_STRING: 'missing-key-requires-string',\n /** `ANY` needs a single value. */\n ANY_REQUIRES_SINGLE_VALUE: 'any-requires-single-value',\n /** The storage cannot deliver a complete projection; select fields explicitly. */\n INCOMPLETE_PROJECTION: 'incomplete-projection',\n /** A metric filter uses a search filter. */\n METRIC_FILTER_SEARCH: 'metric-filter-search',\n /** A metric filter uses `ELEMENT_MATCH`. */\n METRIC_FILTER_ELEMENT_MATCH: 'metric-filter-element-match',\n /** A metric filter names an array field; it must be scalar. */\n METRIC_FILTER_ARRAY_FIELD: 'metric-filter-array-field',\n /** The field cannot be projected. */\n NOT_PROJECTABLE: 'not-projectable',\n /** An event projection that keeps payloads must keep their `bodyType`. */\n EVENT_PROJECTION_TYPE_REQUIRED: 'event-projection-type-required',\n /** A relative-time filter needs a field with a known temporal representation. */\n TEMPORAL_REPRESENTATION_REQUIRED: 'temporal-representation-required',\n /**\n * A sort names two array fields on independent arrays, which the storage\n * cannot order by together; `path` is the second of them. The descriptor\n * lists such fields under a `PARALLEL_ARRAY_SORT` constraint.\n */\n PARALLEL_ARRAY_SORT: 'parallel-array-sort',\n /**\n * An `EQ` or `NE` compares the field to an array, which the storage cannot\n * do: it takes only a scalar operand. The descriptor says so with an\n * `ARRAY_EQUALITY` constraint.\n */\n ARRAY_EQUALITY: 'array-equality',\n /**\n * A `FIRST` or `LAST` metric names a field that may hold several values;\n * it needs a single-valued one (`aggregate.firstLast` in the descriptor).\n */\n FIRST_LAST_REQUIRES_SINGLE_VALUE: 'first-last-requires-single-value',\n /**\n * A `FIRST` or `LAST` metric names no `orderBy` where there is no event\n * time to order by, such as inside an element or on a model whose\n * descriptor has no `analysis.firstLastOrderBy`; `path` is its field.\n */\n FIRST_LAST_REQUIRES_ORDER_BY: 'first-last-requires-order-by',\n /**\n * A date group or date difference names a field that stores neither a\n * date nor an epoch (a formatted string, say), so it cannot be aggregated\n * by time.\n */\n TEMPORAL_AGGREGATION_UNSUPPORTED: 'temporal-aggregation-unsupported',\n /** The sort has more fields than the protocol allows; `path` is `''`. */\n SORT_TOO_MANY: 'sort-too-many',\n /** Two sort fields name the same stored field; `path` is the second. */\n SORT_FIELD_DUPLICATE: 'sort-field-duplicate',\n /**\n * An identity filter or a cursor on a model that defines no record\n * identity; `path` is `''`.\n */\n IDENTITY_UNDEFINED: 'identity-undefined',\n /**\n * The storage does not support the feature the query uses, or its native\n * query language cannot express it (a MongoDB PHRASE search with a quote,\n * say); `path` is the field, or `''`.\n */\n STORAGE_UNSUPPORTED: 'storage-unsupported',\n /**\n * A `PREVIOUS` window steps along a date group whose field the filter\n * conditions where its range cannot be shifted to the earlier period:\n * outside the top-level `AND`, or with a value that is not an instant;\n * `path` is the field.\n */\n PREVIOUS_UNSHIFTABLE: 'previous-unshiftable',\n} as const);\n\n/** One of the codes this package knows; see {@link QueryErrorCodes}. */\nexport type KnownQueryErrorCode =\n (typeof QueryErrorCodes)[keyof typeof QueryErrorCodes];\n\n/**\n * The code of a rejected query: one this package knows, which editors\n * complete, or one a newer server added.\n */\nexport type QueryErrorCode = KnownQueryErrorCode | (string & {});\n\n/**\n * Why the server rejected a query: one violation of its `wow.query.invalid`\n * problem, which rule failed, where, and the server's words.\n */\nexport interface QueryViolation {\n /** Which rule failed; switch on it against {@link QueryErrorCodes}. */\n code: QueryErrorCode;\n /**\n * Where: the JSON path of the offending value for a decoding error\n * (`filter.state`, `metrics[0]`, `body`), the absolute logical field path\n * for an admission error (`state.items.sku`), or `''` when the rule is about\n * the model rather than a field.\n */\n path: string;\n /** The server's words. */\n message: string;\n}\n"],"mappings":";AAkCA,IAAaA,IAAkB,OAAO,OAAO;CAE3C,cAAc;CAEd,iBAAiB;CAEjB,YAAY;CAEZ,kBAAkB;CAElB,cAAc;CAEd,eAAe;CAEf,eAAe;CAEf,iBAAiB;CAEjB,uBAAuB;CAEvB,sBAAsB;CAKtB,gBAAgB;CAMhB,sBAAsB;CAMtB,mBAAmB;CAKnB,kBAAkB;CAOlB,6BAA6B;CAK7B,uBAAuB;CAMvB,0BAA0B;CAK1B,iBAAiB;CAKjB,yBAAyB;CAMzB,iBAAiB;CAEjB,eAAe;CAEf,wBAAwB;CAExB,wBAAwB;CAExB,gBAAgB;CAEhB,gBAAgB;CAEhB,mBAAmB;CAEnB,0BAA0B;CAE1B,oBAAoB;CAEpB,uBAAuB;CAMvB,sBAAsB;CAEtB,6BAA6B;CAE7B,2BAA2B;CAE3B,uBAAuB;CAEvB,sBAAsB;CAEtB,6BAA6B;CAE7B,2BAA2B;CAE3B,iBAAiB;CAEjB,gCAAgC;CAEhC,kCAAkC;CAMlC,qBAAqB;CAMrB,gBAAgB;CAKhB,kCAAkC;CAMlC,8BAA8B;CAM9B,kCAAkC;CAElC,eAAe;CAEf,sBAAsB;CAKtB,oBAAoB;CAMpB,qBAAqB;CAOrB,sBAAsB;AACxB,CAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryFilter.cjs","names":["filter","filters","require_builders","queryFilter","filter$1"],"sources":["../../src/dsl/queryFilter.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 { filter as filters, type FilterExpression } from './filter/index.js';\n\n/** The filter a query builder sends: the one given, or `filter.matchAll()`. */\nexport function queryFilter<FIELDS extends string>(\n filter: FilterExpression<FIELDS> | undefined,\n): FilterExpression<FIELDS> {\n if (filter === null) {\n throw new TypeError('filter cannot be null.');\n }\n return filter ?? filters.matchAll();\n}\n"],"mappings":"A,yCAgBA,SAAgBG,EACd,EAC0B,CAC1B,GAAIH,IAAW,KACb,MAAU,UAAU,wBAAwB,EAE9C,OAAOA,GAAUC,EAAAA,OAAQ,SAAS,CACpC,C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { filter as e } from "./filter/builders.es.js";
|
|
2
|
+
// src/dsl/queryFilter.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
if (t === null) throw TypeError("filter cannot be null.");
|
|
5
|
+
return t ?? e.matchAll();
|
|
6
|
+
}
|
|
7
|
+
export { t as queryFilter };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=queryFilter.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryFilter.es.js","names":["filter","filters","queryFilter","filter$1","filter"],"sources":["../../src/dsl/queryFilter.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 { filter as filters, type FilterExpression } from './filter/index.js';\n\n/** The filter a query builder sends: the one given, or `filter.matchAll()`. */\nexport function queryFilter<FIELDS extends string>(\n filter: FilterExpression<FIELDS> | undefined,\n): FilterExpression<FIELDS> {\n if (filter === null) {\n throw new TypeError('filter cannot be null.');\n }\n return filter ?? filters.matchAll();\n}\n"],"mappings":";;AAgBA,SAAgBE,EACd,GAC0B;CAC1B,IAAIF,MAAW,MACb,MAAU,UAAU,wBAAwB;CAE9C,OAAOA,KAAUC,EAAQ,SAAS;AACpC"}
|
package/dist/dsl/queryable.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./
|
|
1
|
+
const e=require("./pagination.cjs"),t=require("./queryFilter.cjs");function n({filter:e,projection:n,sort:r}={}){return{filter:t.queryFilter(e),projection:n,sort:r}}function r({filter:e,projection:n,sort:r,limit:i}={}){return{filter:t.queryFilter(e),projection:n,sort:r,limit:i}}function i({filter:n,projection:r,sort:i,pagination:a={...e.DEFAULT_PAGINATION}}={}){return{filter:t.queryFilter(n),projection:r,sort:i,pagination:a}}function a({total:e,exact:t=!0,list:n=[]}={}){return{total:e===void 0?n.length:e,exact:t,list:n}}exports.listQuery=r,exports.pagedList=a,exports.pagedQuery=i,exports.singleQuery=n;
|
|
2
2
|
//# sourceMappingURL=queryable.cjs.map
|