@ahoo-wang/wow-client 10.0.0-beta.3 → 10.0.0-beta.4
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/dist/commands.cjs +1 -1
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +15 -3
- package/dist/commands.d.ts +15 -3
- package/dist/commands.es.js +46 -46
- 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 +96 -96
- package/dist/dsl/aggregation/builders.cjs +1 -1
- package/dist/dsl/aggregation/builders.cjs.map +1 -1
- package/dist/dsl/aggregation/builders.es.js +32 -32
- package/dist/dsl/aggregation/derived.cjs +1 -1
- package/dist/dsl/aggregation/derived.cjs.map +1 -1
- package/dist/dsl/aggregation/derived.es.js +11 -11
- package/dist/dsl/aggregation/groups.cjs +1 -1
- package/dist/dsl/aggregation/groups.cjs.map +1 -1
- package/dist/dsl/aggregation/groups.es.js +22 -22
- package/dist/dsl/aggregation/having.cjs +1 -1
- package/dist/dsl/aggregation/having.cjs.map +1 -1
- package/dist/dsl/aggregation/having.es.js +11 -11
- package/dist/dsl/filter/expressionFilter.cjs +1 -1
- package/dist/dsl/filter/expressionFilter.cjs.map +1 -1
- package/dist/dsl/filter/expressionFilter.es.js +7 -7
- package/dist/dsl/filter/fieldFilters.cjs +1 -1
- package/dist/dsl/filter/fieldFilters.cjs.map +1 -1
- package/dist/dsl/filter/fieldFilters.es.js +61 -61
- package/dist/dsl/filter/logicalFilters.cjs +1 -1
- package/dist/dsl/filter/logicalFilters.cjs.map +1 -1
- package/dist/dsl/filter/logicalFilters.es.js +19 -19
- package/dist/dsl/filter/metadataFilters.cjs +1 -1
- package/dist/dsl/filter/metadataFilters.cjs.map +1 -1
- package/dist/dsl/filter/metadataFilters.es.js +31 -31
- package/dist/dsl/filter/scope.cjs +1 -1
- package/dist/dsl/filter/scope.cjs.map +1 -1
- package/dist/dsl/filter/scope.es.js +18 -18
- package/dist/dsl/filter/searchFilter.cjs +1 -1
- package/dist/dsl/filter/searchFilter.cjs.map +1 -1
- package/dist/dsl/filter/searchFilter.es.js +6 -6
- package/dist/dsl/filter/timeFilters.cjs +1 -1
- package/dist/dsl/filter/timeFilters.cjs.map +1 -1
- package/dist/dsl/filter/timeFilters.es.js +47 -47
- package/dist/dsl/filter/validate.cjs +1 -1
- package/dist/dsl/filter/validate.cjs.map +1 -1
- package/dist/dsl/filter/validate.es.js +8 -8
- package/dist/dsl/queryable.cjs +1 -1
- package/dist/dsl/queryable.cjs.map +1 -1
- package/dist/dsl/queryable.es.js +8 -8
- package/dist/dsl.cjs +1 -1
- package/dist/dsl.es.js +12 -12
- package/dist/index.cjs +1 -1
- package/dist/index.es.js +12 -12
- package/dist/manifest.cjs +1 -1
- package/dist/manifest.cjs.map +1 -1
- package/dist/manifest.es.js +11 -11
- package/dist/state.cjs +1 -1
- package/dist/state.cjs.map +1 -1
- package/dist/state.es.js +22 -22
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchFilter.cjs","names":["SearchMode","FilterOperator","queryField","
|
|
1
|
+
{"version":3,"file":"searchFilter.cjs","names":["SearchMode","FilterOperator","queryField","require_field","require_operator","search","query","options","mode","fields","searchFilters"],"sources":["../../../src/dsl/filter/searchFilter.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, SearchMode } from './operator.js';\nimport type {\n SearchFilter,\n SearchFilterOptions,\n ElementSearchFilter,\n QueryField,\n} from './types.js';\n\n/**\n * The overloads of {@link searchFilters.search | `filter.search`}: naming at least one field, as an\n * array literal, types the result as an {@link ElementSearchFilter}, which\n * `ELEMENT_MATCH` takes; otherwise it is a {@link SearchFilter}, root-only\n * when its `fields` are empty.\n */\nexport interface SearchBuilder {\n <FIELDS extends string>(\n query: string,\n options: SearchFilterOptions<FIELDS> & {\n fields: readonly [QueryField<FIELDS>, ...QueryField<FIELDS>[]];\n },\n ): ElementSearchFilter<FIELDS>;\n <FIELDS extends string>(\n query: string,\n options?: SearchFilterOptions<FIELDS>,\n ): SearchFilter<FIELDS>;\n}\n\nfunction search<FIELDS extends string>(\n query: string,\n options?: SearchFilterOptions<FIELDS>,\n): SearchFilter<FIELDS> {\n if (typeof query !== 'string' || !query.trim()) {\n throw new TypeError('SEARCH query cannot be blank.');\n }\n if (\n options !== undefined &&\n (options === null || typeof options !== 'object' || Array.isArray(options))\n ) {\n throw new TypeError('SEARCH options must be a non-null object.');\n }\n const { fields = [], mode = SearchMode.TERMS } = options ?? {};\n if (!Object.values(SearchMode).includes(mode)) {\n throw new TypeError(`SEARCH mode is invalid: [${String(mode)}].`);\n }\n return {\n op: FilterOperator.SEARCH,\n query,\n mode,\n fields: fields.map(queryField),\n };\n}\n\n/** The full-text search filter. */\nexport const searchFilters = {\n /**\n * Matches records by full-text search. Tokenization and matching depend on\n * the backend's analyzer. Inside `elementMatch` it must name its fields,\n * relative to the element; with fields given as a non-empty array literal\n * it returns an {@link ElementSearchFilter}, which `elementMatch` takes.\n *\n * @param query - Search text.\n * @param options - Optional `fields` (defaults to `[]`, the backend's default\n * search fields) and `mode` (defaults to `SearchMode.TERMS`).\n * @returns `{ op: 'search', query, mode, fields }`.\n * @throws TypeError If `query` is not a string or is blank, `options` is\n * given but is `null`, an array or not an object, `mode` is not a\n * {@link SearchMode} member, or any of `fields` is not a valid query field\n * path.\n * @example\n * ```typescript\n * filter.search('event sourcing', {\n * fields: ['state.description'],\n * mode: SearchMode.PHRASE,\n * });\n * ```\n */\n search: search as SearchBuilder,\n};\n"],"mappings":"A,4DAyCA,SAASK,EACP,EACA,EACsB,CACtB,GAAI,OAAOC,GAAU,UAAY,CAACA,EAAM,KAAK,EAC3C,MAAU,UAAU,+BAA+B,EAErD,GACEC,IAAY,IAAA,KACS,OAAOA,GAAY,WAAvCA,GAAmD,MAAM,QAAQA,CAAO,GAEzE,MAAU,UAAU,2CAA2C,EAEjE,GAAM,CAAE,SAAS,CAAC,EAAG,OAAOP,EAAAA,WAAW,OAAUO,GAAW,CAAC,EAC7D,GAAI,CAAC,OAAO,OAAOP,EAAAA,UAAU,CAAC,CAAC,SAASQ,CAAI,EAC1C,MAAU,UAAU,4BAA4B,OAAOA,CAAI,EAAE,GAAG,EAElE,MAAO,CACL,GAAIP,EAAAA,eAAe,OACnB,QACA,OACA,OAAQQ,EAAO,IAAIP,EAAAA,UAAU,CAC/B,CACF,CAGA,IAAaQ,EAAgB,CAuBnB,QACV,E"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { queryField as e } from "../field.es.js";
|
|
2
|
+
import { FilterOperator as t, SearchMode as n } from "./operator.es.js";
|
|
3
3
|
// src/dsl/filter/searchFilter.ts
|
|
4
4
|
function r(r, i) {
|
|
5
5
|
if (typeof r != "string" || !r.trim()) throw TypeError("SEARCH query cannot be blank.");
|
|
6
6
|
if (i !== void 0 && (typeof i != "object" || !i || Array.isArray(i))) throw TypeError("SEARCH options must be a non-null object.");
|
|
7
|
-
let { fields: a = [], mode: o =
|
|
8
|
-
if (!Object.values(
|
|
7
|
+
let { fields: a = [], mode: o = n.TERMS } = i ?? {};
|
|
8
|
+
if (!Object.values(n).includes(o)) throw TypeError(`SEARCH mode is invalid: [${String(o)}].`);
|
|
9
9
|
return {
|
|
10
|
-
op:
|
|
10
|
+
op: t.SEARCH,
|
|
11
11
|
query: r,
|
|
12
12
|
mode: o,
|
|
13
|
-
fields: a.map(
|
|
13
|
+
fields: a.map(e)
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
var i = { search: r };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("
|
|
1
|
+
const e=require("../field.cjs"),t=require("./operator.cjs"),n=require("./validate.cjs");function r(t,r,i){return{...n.validateRelativeTimeOptions(i),op:t,field:e.queryField(r)}}function i(t,r,i,a){return n.validateDays(t,i),{...n.validateRelativeTimeOptions(a),op:t,field:e.queryField(r),days:i}}function a(t,r,i,a){return n.requireDuration(t,i),{...n.validateRelativeTimeOptions(a),op:t,field:e.queryField(r),offset:i}}var o={today(e,n={}){return r(t.FilterOperator.TODAY,e,n)},beforeToday(r,i,a={}){let o=n.requireLocalTime(i);return{...n.validateRelativeTimeOptions(a),op:t.FilterOperator.BEFORE_TODAY,field:e.queryField(r),time:o}},tomorrow(e,n={}){return r(t.FilterOperator.TOMORROW,e,n)},thisWeek(e,n={}){return r(t.FilterOperator.THIS_WEEK,e,n)},nextWeek(e,n={}){return r(t.FilterOperator.NEXT_WEEK,e,n)},lastWeek(e,n={}){return r(t.FilterOperator.LAST_WEEK,e,n)},thisMonth(e,n={}){return r(t.FilterOperator.THIS_MONTH,e,n)},lastMonth(e,n={}){return r(t.FilterOperator.LAST_MONTH,e,n)},yesterday(e,n={}){return r(t.FilterOperator.YESTERDAY,e,n)},nextMonth(e,n={}){return r(t.FilterOperator.NEXT_MONTH,e,n)},lastYear(e,n={}){return r(t.FilterOperator.LAST_YEAR,e,n)},thisYear(e,n={}){return r(t.FilterOperator.THIS_YEAR,e,n)},nextYear(e,n={}){return r(t.FilterOperator.NEXT_YEAR,e,n)},recentDays(e,n,r={}){return i(t.FilterOperator.RECENT_DAYS,e,n,r)},earlierDays(e,n,r={}){return i(t.FilterOperator.EARLIER_DAYS,e,n,r)},beforeNow(e,n=`PT0S`,r={}){return a(t.FilterOperator.BEFORE_NOW,e,n,r)},afterNow(e,n=`PT0S`,r={}){return a(t.FilterOperator.AFTER_NOW,e,n,r)}};exports.timeFilters=o;
|
|
2
2
|
//# sourceMappingURL=timeFilters.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeFilters.cjs","names":["validateRelativeTimeOptions","queryField","FilterOperator","requireLocalTime","require_operator","require_field","require_validate","calendar","options","field","dayWindow","op","days","nowRelative","offset","timeFilters","localTime","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":"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"}
|
|
1
|
+
{"version":3,"file":"timeFilters.cjs","names":["validateRelativeTimeOptions","queryField","FilterOperator","requireLocalTime","require_field","require_operator","require_validate","calendar","options","field","dayWindow","op","days","nowRelative","offset","timeFilters","localTime","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":"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"}
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { queryField as e } from "../field.es.js";
|
|
2
|
+
import { FilterOperator as t } from "./operator.es.js";
|
|
3
3
|
import { requireDuration as n, requireLocalTime as r, validateDays as i, validateRelativeTimeOptions as a } from "./validate.es.js";
|
|
4
4
|
// src/dsl/filter/timeFilters.ts
|
|
5
|
-
function o(
|
|
5
|
+
function o(t, n, r) {
|
|
6
6
|
return {
|
|
7
7
|
...a(r),
|
|
8
|
-
op:
|
|
9
|
-
field:
|
|
8
|
+
op: t,
|
|
9
|
+
field: e(n)
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
function s(
|
|
13
|
-
return i(
|
|
12
|
+
function s(t, n, r, o) {
|
|
13
|
+
return i(t, r), {
|
|
14
14
|
...a(o),
|
|
15
|
-
op:
|
|
16
|
-
field:
|
|
15
|
+
op: t,
|
|
16
|
+
field: e(n),
|
|
17
17
|
days: r
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
function c(
|
|
21
|
-
return n(
|
|
20
|
+
function c(t, r, i, o) {
|
|
21
|
+
return n(t, i), {
|
|
22
22
|
...a(o),
|
|
23
|
-
op:
|
|
24
|
-
field:
|
|
23
|
+
op: t,
|
|
24
|
+
field: e(r),
|
|
25
25
|
offset: i
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
var l = {
|
|
29
|
-
today(
|
|
30
|
-
return o(
|
|
29
|
+
today(e, n = {}) {
|
|
30
|
+
return o(t.TODAY, e, n);
|
|
31
31
|
},
|
|
32
32
|
beforeToday(n, i, o = {}) {
|
|
33
33
|
let s = r(i);
|
|
34
34
|
return {
|
|
35
35
|
...a(o),
|
|
36
|
-
op:
|
|
37
|
-
field:
|
|
36
|
+
op: t.BEFORE_TODAY,
|
|
37
|
+
field: e(n),
|
|
38
38
|
time: s
|
|
39
39
|
};
|
|
40
40
|
},
|
|
41
|
-
tomorrow(
|
|
42
|
-
return o(
|
|
41
|
+
tomorrow(e, n = {}) {
|
|
42
|
+
return o(t.TOMORROW, e, n);
|
|
43
43
|
},
|
|
44
|
-
thisWeek(
|
|
45
|
-
return o(
|
|
44
|
+
thisWeek(e, n = {}) {
|
|
45
|
+
return o(t.THIS_WEEK, e, n);
|
|
46
46
|
},
|
|
47
|
-
nextWeek(
|
|
48
|
-
return o(
|
|
47
|
+
nextWeek(e, n = {}) {
|
|
48
|
+
return o(t.NEXT_WEEK, e, n);
|
|
49
49
|
},
|
|
50
|
-
lastWeek(
|
|
51
|
-
return o(
|
|
50
|
+
lastWeek(e, n = {}) {
|
|
51
|
+
return o(t.LAST_WEEK, e, n);
|
|
52
52
|
},
|
|
53
|
-
thisMonth(
|
|
54
|
-
return o(
|
|
53
|
+
thisMonth(e, n = {}) {
|
|
54
|
+
return o(t.THIS_MONTH, e, n);
|
|
55
55
|
},
|
|
56
|
-
lastMonth(
|
|
57
|
-
return o(
|
|
56
|
+
lastMonth(e, n = {}) {
|
|
57
|
+
return o(t.LAST_MONTH, e, n);
|
|
58
58
|
},
|
|
59
|
-
yesterday(
|
|
60
|
-
return o(
|
|
59
|
+
yesterday(e, n = {}) {
|
|
60
|
+
return o(t.YESTERDAY, e, n);
|
|
61
61
|
},
|
|
62
|
-
nextMonth(
|
|
63
|
-
return o(
|
|
62
|
+
nextMonth(e, n = {}) {
|
|
63
|
+
return o(t.NEXT_MONTH, e, n);
|
|
64
64
|
},
|
|
65
|
-
lastYear(
|
|
66
|
-
return o(
|
|
65
|
+
lastYear(e, n = {}) {
|
|
66
|
+
return o(t.LAST_YEAR, e, n);
|
|
67
67
|
},
|
|
68
|
-
thisYear(
|
|
69
|
-
return o(
|
|
68
|
+
thisYear(e, n = {}) {
|
|
69
|
+
return o(t.THIS_YEAR, e, n);
|
|
70
70
|
},
|
|
71
|
-
nextYear(
|
|
72
|
-
return o(
|
|
71
|
+
nextYear(e, n = {}) {
|
|
72
|
+
return o(t.NEXT_YEAR, e, n);
|
|
73
73
|
},
|
|
74
|
-
recentDays(
|
|
75
|
-
return s(
|
|
74
|
+
recentDays(e, n, r = {}) {
|
|
75
|
+
return s(t.RECENT_DAYS, e, n, r);
|
|
76
76
|
},
|
|
77
|
-
earlierDays(
|
|
78
|
-
return s(
|
|
77
|
+
earlierDays(e, n, r = {}) {
|
|
78
|
+
return s(t.EARLIER_DAYS, e, n, r);
|
|
79
79
|
},
|
|
80
|
-
beforeNow(
|
|
81
|
-
return c(
|
|
80
|
+
beforeNow(e, n = "PT0S", r = {}) {
|
|
81
|
+
return c(t.BEFORE_NOW, e, n, r);
|
|
82
82
|
},
|
|
83
|
-
afterNow(
|
|
84
|
-
return c(
|
|
83
|
+
afterNow(e, n = "PT0S", r = {}) {
|
|
84
|
+
return c(t.AFTER_NOW, e, n, r);
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
export { l as timeFilters };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("
|
|
1
|
+
const e=require("../constantName.cjs"),t=require("./operator.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(e){if(e!==t.StringComparison.CASE_SENSITIVE&&e!==t.StringComparison.CASE_INSENSITIVE)throw TypeError(`String comparison is invalid: [${String(e)}].`)}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(t,n){if(!Number.isInteger(n)||n<1||n>2147483647)throw TypeError(`${e.constantName(t)} days must be a positive JVM Int.`)}function p(t,n){if(typeof n!=`string`||!a.test(n))throw TypeError(`${e.constantName(t)} 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","constantName","
|
|
1
|
+
{"version":3,"file":"validate.cjs","names":["StringComparison","constantName","require_constantName","require_operator","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,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { constantName as e } from "../constantName.es.js";
|
|
2
|
+
import { StringComparison as t } from "./operator.es.js";
|
|
3
3
|
// src/dsl/filter/validate.ts
|
|
4
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
5
|
function o(e, t) {
|
|
@@ -10,8 +10,8 @@ function s(e, t) {
|
|
|
10
10
|
if (typeof t != "string") throw TypeError(`${e} must be a string.`);
|
|
11
11
|
return t;
|
|
12
12
|
}
|
|
13
|
-
function c(
|
|
14
|
-
if (
|
|
13
|
+
function c(e) {
|
|
14
|
+
if (e !== t.CASE_SENSITIVE && e !== t.CASE_INSENSITIVE) throw TypeError(`String comparison is invalid: [${String(e)}].`);
|
|
15
15
|
}
|
|
16
16
|
function l(e, t) {
|
|
17
17
|
if (t.length === 0) throw TypeError(`${e} cannot be empty.`);
|
|
@@ -34,11 +34,11 @@ function d({ timeZone: e }) {
|
|
|
34
34
|
}
|
|
35
35
|
return e === void 0 ? {} : { timeZone: e };
|
|
36
36
|
}
|
|
37
|
-
function f(
|
|
38
|
-
if (!Number.isInteger(n) || n < 1 || n > 2147483647) throw TypeError(`${t
|
|
37
|
+
function f(t, n) {
|
|
38
|
+
if (!Number.isInteger(n) || n < 1 || n > 2147483647) throw TypeError(`${e(t)} days must be a positive JVM Int.`);
|
|
39
39
|
}
|
|
40
|
-
function p(
|
|
41
|
-
if (typeof n != "string" || !a.test(n)) throw TypeError(`${t
|
|
40
|
+
function p(t, n) {
|
|
41
|
+
if (typeof n != "string" || !a.test(n)) throw TypeError(`${e(t)} offset must be an ISO-8601 duration such as PT0S or -PT30M.`);
|
|
42
42
|
return n;
|
|
43
43
|
}
|
|
44
44
|
function m(e) {
|
package/dist/dsl/queryable.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./
|
|
1
|
+
const e=require("./queryFilter.cjs"),t=require("./pagination.cjs");function n({filter:t,projection:n,sort:r}={}){return{filter:e.queryFilter(t),projection:n,sort:r}}function r({filter:t,projection:n,sort:r,limit:i}={}){return{filter:e.queryFilter(t),projection:n,sort:r,limit:i}}function i({filter:n,projection:r,sort:i,pagination:a={...t.DEFAULT_PAGINATION}}={}){return{filter:e.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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryable.cjs","names":["queryFilter","DEFAULT_PAGINATION","
|
|
1
|
+
{"version":3,"file":"queryable.cjs","names":["queryFilter","DEFAULT_PAGINATION","require_queryFilter","require_pagination","singleQuery","filter","listQuery","pagedQuery","pagedList","total","list"],"sources":["../../src/dsl/queryable.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type FilterCapable } from './filter/index.js';\nimport { queryFilter } from './queryFilter.js';\nimport { type SortCapable } from './sort.js';\nimport { DEFAULT_PAGINATION, type Pagination } from './pagination.js';\nimport { type ProjectionCapable } from './projection.js';\n\n/** A query that filters, projects and sorts with Wow's `FilterExpression`. */\nexport interface FilterQueryable<FIELDS extends string = string>\n extends\n FilterCapable<FIELDS>,\n ProjectionCapable<FIELDS>,\n SortCapable<FIELDS> {}\n\n/** The body of a `single` query: the first match of the filter, or nothing. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FilterSingleQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {}\n\n/** The body of a `list` or `stream` query. */\nexport interface FilterListQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {\n /**\n * The most rows to return, at least 1. Absent, the server applies its\n * default list size (100 unless it configures another). A limit below 1 is\n * refused with 400 `wow.query.malformed`, and so is a value above the\n * server's maximum list size (1000 by default) with 400\n * `wow.query.invalid`.\n */\n limit?: number;\n}\n\n/** The body of a `paged` query. */\nexport interface FilterPagedQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {\n pagination?: Pagination;\n}\n\n/** How a paged query counts its total (`TotalMode`). */\nexport type TotalMode = 'exact' | 'bounded' | 'none';\n\n/** A paged query of a query route: a page, and how its total is counted. */\nexport interface PagedQuery<\n FIELDS extends string = string,\n> extends FilterPagedQuery<FIELDS> {\n /** `bounded` (the server's default) counts up to the budget's limit. */\n total?: TotalMode;\n}\n\n/**\n * A page of a paged query: `total` is exact when `exact`, a lower bound\n * otherwise, and null for total `none`. Kotlin's `PagedList`.\n */\nexport interface PagedList<T> {\n readonly total: number | null;\n readonly exact: boolean;\n readonly list: readonly T[];\n}\n\n/** What `singleQuery`, `listQuery` and `pagedQuery` take in common. */\ntype QueryOptions<FIELDS extends string = string> = Partial<\n FilterQueryable<FIELDS>\n>;\n\n/**\n * Builds the body of a `single` query.\n *\n * @param options.filter - What to match. Defaults to `filter.matchAll()`.\n * @param options.projection - Which fields to return. Optional.\n * @param options.sort - Which match counts as the first. Optional.\n * @throws TypeError when `filter` is `null`.\n *\n * @example\n * ```typescript\n * singleQuery({ filter: filter.eq('status', 'ACTIVE') });\n * ```\n */\nexport function singleQuery<FIELDS extends string = string>({\n filter,\n projection,\n sort,\n}: QueryOptions<FIELDS> = {}): FilterSingleQuery<FIELDS> {\n return { filter: queryFilter(filter), projection, sort };\n}\n\n/**\n * Builds the body of a `list` or `stream` query.\n *\n * @param options.filter - What to match. Defaults to `filter.matchAll()`.\n * @param options.projection - Which fields to return. Optional.\n * @param options.sort - The order of the rows. Optional.\n * @param options.limit - The most rows to return. Absent is sent as absent:\n * Wow 9.1.5 and later apply the server's default list size, Wow 8.11 to\n * 9.1.3 reject the query, so pass it for those servers; see\n * {@link FilterListQuery.limit}.\n * @throws TypeError when `filter` is `null`.\n *\n * @example\n * ```typescript\n * listQuery({ filter: filter.eq('status', 'ACTIVE'), limit: 20 });\n * ```\n */\nexport function listQuery<FIELDS extends string = string>({\n filter,\n projection,\n sort,\n limit,\n}: QueryOptions<FIELDS> & { limit?: number } = {}): FilterListQuery<FIELDS> {\n return { filter: queryFilter(filter), projection, sort, limit };\n}\n\n/**\n * Builds the body of a `paged` query.\n *\n * @param options.filter - What to match. Defaults to `filter.matchAll()`.\n * @param options.projection - Which fields to return. Optional.\n * @param options.sort - The order of the rows. Optional.\n * @param options.pagination - Which page. Defaults to a copy of\n * {@link DEFAULT_PAGINATION}: the first page of ten.\n * @throws TypeError when `filter` is `null`.\n *\n * @example\n * ```typescript\n * pagedQuery({ filter: filter.matchAll(), pagination: { index: 2, size: 20 } });\n * ```\n */\nexport function pagedQuery<FIELDS extends string = string>({\n filter,\n projection,\n sort,\n pagination = { ...DEFAULT_PAGINATION },\n}: QueryOptions<FIELDS> & {\n pagination?: Pagination;\n} = {}): FilterPagedQuery<FIELDS> {\n return { filter: queryFilter(filter), projection, sort, pagination };\n}\n\n/**\n * Builds a `PagedList`, for a placeholder page or a test double.\n *\n * @param options.total - How many rows match in total. Defaults to the length\n * of `list`.\n * @param options.exact - Whether `total` is exact. Defaults to true.\n * @param options.list - The rows of this page. Defaults to a new empty array.\n */\nexport function pagedList<T>({\n total,\n exact = true,\n list = [],\n}: Partial<PagedList<T>> = {}): PagedList<T> {\n return { total: total === undefined ? list.length : total, exact, list };\n}\n"],"mappings":"A,mEA4FA,SAAgBI,EAA4C,CAC1D,SACA,aACA,QACwB,CAAC,EAA8B,CACvD,MAAO,CAAE,OAAQJ,EAAAA,YAAYK,CAAM,EAAG,aAAY,MAAK,CACzD,CAmBA,SAAgBC,EAA0C,CACxD,SACA,aACA,OACA,SAC6C,CAAC,EAA4B,CAC1E,MAAO,CAAE,OAAQN,EAAAA,YAAYK,CAAM,EAAG,aAAY,OAAM,OAAM,CAChE,CAiBA,SAAgBE,EAA2C,CACzD,SACA,aACA,OACA,aAAa,CAAE,GAAGN,EAAAA,kBAAmB,GAGnC,CAAC,EAA6B,CAChC,MAAO,CAAE,OAAQD,EAAAA,YAAYK,CAAM,EAAG,aAAY,OAAM,YAAW,CACrE,CAUA,SAAgBG,EAAa,CAC3B,QACA,QAAQ,GACR,OAAO,CAAC,GACiB,CAAC,EAAiB,CAC3C,MAAO,CAAE,MAAOC,IAAU,IAAA,GAAYC,EAAK,OAASD,EAAO,QAAO,MAAK,CACzE,C"}
|
package/dist/dsl/queryable.es.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { queryFilter as e } from "./queryFilter.es.js";
|
|
2
|
+
import { DEFAULT_PAGINATION as t } from "./pagination.es.js";
|
|
3
3
|
// src/dsl/queryable.ts
|
|
4
|
-
function n({ filter:
|
|
4
|
+
function n({ filter: t, projection: n, sort: r } = {}) {
|
|
5
5
|
return {
|
|
6
|
-
filter: t
|
|
6
|
+
filter: e(t),
|
|
7
7
|
projection: n,
|
|
8
8
|
sort: r
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
function r({ filter:
|
|
11
|
+
function r({ filter: t, projection: n, sort: r, limit: i } = {}) {
|
|
12
12
|
return {
|
|
13
|
-
filter: t
|
|
13
|
+
filter: e(t),
|
|
14
14
|
projection: n,
|
|
15
15
|
sort: r,
|
|
16
16
|
limit: i
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
function i({ filter: n, projection: r, sort: i, pagination: a = { ...
|
|
19
|
+
function i({ filter: n, projection: r, sort: i, pagination: a = { ...t } } = {}) {
|
|
20
20
|
return {
|
|
21
|
-
filter:
|
|
21
|
+
filter: e(n),
|
|
22
22
|
projection: r,
|
|
23
23
|
sort: i,
|
|
24
24
|
pagination: a
|
package/dist/dsl.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./dsl/filter/operator.cjs"),t=require("./dsl/aggregation/types.cjs"),n=require("./dsl/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./dsl/filter/operator.cjs"),t=require("./dsl/aggregation/types.cjs"),n=require("./dsl/sort.cjs"),r=require("./dsl/filter/builders.cjs"),i=require("./dsl/aggregation/groups.cjs"),a=require("./dsl/aggregation/metrics.cjs"),o=require("./dsl/aggregation/derived.cjs"),s=require("./dsl/aggregation/having.cjs"),c=require("./dsl/projection.cjs"),l=require("./dsl/aggregation/builders.cjs"),u=require("./dsl/pagination.cjs"),d=require("./dsl/cursorQuery.cjs"),f=require("./dsl/queryable.cjs"),p=require("./dsl/deletionState.cjs"),m=require("./dsl/descriptor.cjs"),h=require("./dsl/fieldDescriptor.cjs"),g=require("./dsl/semanticTypes.cjs"),_=require("./dsl/queryErrorCodes.cjs");exports.AGGREGATION_LIMITS=t.AGGREGATION_LIMITS,exports.AggregationDatePart=i.AggregationDatePart,exports.AggregationDateUnit=i.AggregationDateUnit,exports.AggregationExpressionOperator=t.AggregationExpressionOperator,exports.AggregationExpressionType=t.AggregationExpressionType,exports.AggregationFunction=a.AggregationFunction,exports.AggregationGroupScope=i.AggregationGroupScope,exports.AggregationGroupType=i.AggregationGroupType,exports.AggregationMetricType=a.AggregationMetricType,exports.ComparisonOperator=t.ComparisonOperator,exports.DEFAULT_PAGINATION=u.DEFAULT_PAGINATION,exports.DateDiffUnit=t.DateDiffUnit,exports.DeletionState=p.DeletionState,exports.DerivedExpressionType=o.DerivedExpressionType,exports.FilterOperator=e.FilterOperator,exports.HavingExpressionType=s.HavingExpressionType,exports.MAX_CURSOR_SIZE=d.MAX_CURSOR_SIZE,exports.MAX_CURSOR_SORT_FIELDS=d.MAX_CURSOR_SORT_FIELDS,exports.PagingMode=m.PagingMode,exports.QueryConstraintTypes=m.QueryConstraintTypes,exports.QueryErrorCodes=_.QueryErrorCodes,exports.QueryFieldRoles=h.QueryFieldRoles,exports.QueryModels=m.QueryModels,exports.QuerySemanticTypes=g.QuerySemanticTypes,exports.QueryValueKind=h.QueryValueKind,exports.QueryValueTypes=h.QueryValueTypes,exports.RunningFunction=o.RunningFunction,exports.SearchMode=e.SearchMode,exports.SensitivityLevel=h.SensitivityLevel,exports.SortDirection=n.SortDirection,exports.StringComparison=e.StringComparison,exports.TimeUnit=e.TimeUnit,exports.WindowFunction=o.WindowFunction,exports.aggregation=l.aggregation,exports.asc=n.asc,exports.cursorQuery=d.cursorQuery,exports.desc=n.desc,exports.filter=r.filter,exports.listQuery=f.listQuery,exports.pagedList=f.pagedList,exports.pagedQuery=f.pagedQuery,exports.pagination=u.pagination,exports.projection=c.projection,exports.singleQuery=f.singleQuery;
|
package/dist/dsl.es.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { FilterOperator as e, SearchMode as t, StringComparison as n, TimeUnit as r } from "./dsl/filter/operator.es.js";
|
|
2
2
|
import { AGGREGATION_LIMITS as i, AggregationExpressionOperator as a, AggregationExpressionType as o, ComparisonOperator as s, DateDiffUnit as c } from "./dsl/aggregation/types.es.js";
|
|
3
|
-
import {
|
|
4
|
-
import { filter as
|
|
5
|
-
import { AggregationDatePart as
|
|
6
|
-
import { AggregationFunction as
|
|
7
|
-
import { DerivedExpressionType as
|
|
8
|
-
import { HavingExpressionType as
|
|
9
|
-
import {
|
|
3
|
+
import { SortDirection as l, asc as u, desc as d } from "./dsl/sort.es.js";
|
|
4
|
+
import { filter as f } from "./dsl/filter/builders.es.js";
|
|
5
|
+
import { AggregationDatePart as p, AggregationDateUnit as m, AggregationGroupScope as h, AggregationGroupType as g } from "./dsl/aggregation/groups.es.js";
|
|
6
|
+
import { AggregationFunction as _, AggregationMetricType as v } from "./dsl/aggregation/metrics.es.js";
|
|
7
|
+
import { DerivedExpressionType as y, RunningFunction as b, WindowFunction as x } from "./dsl/aggregation/derived.es.js";
|
|
8
|
+
import { HavingExpressionType as S } from "./dsl/aggregation/having.es.js";
|
|
9
|
+
import { projection as C } from "./dsl/projection.es.js";
|
|
10
10
|
import { aggregation as w } from "./dsl/aggregation/builders.es.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { DEFAULT_PAGINATION as T, pagination as E } from "./dsl/pagination.es.js";
|
|
12
|
+
import { MAX_CURSOR_SIZE as D, MAX_CURSOR_SORT_FIELDS as O, cursorQuery as k } from "./dsl/cursorQuery.es.js";
|
|
13
|
+
import { listQuery as A, pagedList as j, pagedQuery as M, singleQuery as N } from "./dsl/queryable.es.js";
|
|
14
|
+
import { DeletionState as P } from "./dsl/deletionState.es.js";
|
|
15
15
|
import { PagingMode as F, QueryConstraintTypes as I, QueryModels as L } from "./dsl/descriptor.es.js";
|
|
16
16
|
import { QueryFieldRoles as R, QueryValueKind as z, QueryValueTypes as B, SensitivityLevel as V } from "./dsl/fieldDescriptor.es.js";
|
|
17
17
|
import { QuerySemanticTypes as H } from "./dsl/semanticTypes.es.js";
|
|
18
18
|
import { QueryErrorCodes as U } from "./dsl/queryErrorCodes.es.js";
|
|
19
|
-
export { i as AGGREGATION_LIMITS,
|
|
19
|
+
export { i as AGGREGATION_LIMITS, p as AggregationDatePart, m as AggregationDateUnit, a as AggregationExpressionOperator, o as AggregationExpressionType, _ as AggregationFunction, h as AggregationGroupScope, g as AggregationGroupType, v as AggregationMetricType, s as ComparisonOperator, T as DEFAULT_PAGINATION, c as DateDiffUnit, P as DeletionState, y as DerivedExpressionType, e as FilterOperator, S as HavingExpressionType, D as MAX_CURSOR_SIZE, O as MAX_CURSOR_SORT_FIELDS, F as PagingMode, I as QueryConstraintTypes, U as QueryErrorCodes, R as QueryFieldRoles, L as QueryModels, H as QuerySemanticTypes, z as QueryValueKind, B as QueryValueTypes, b as RunningFunction, t as SearchMode, V as SensitivityLevel, l as SortDirection, n as StringComparison, r as TimeUnit, x as WindowFunction, w as aggregation, u as asc, k as cursorQuery, d as desc, f as filter, A as listQuery, j as pagedList, M as pagedQuery, E as pagination, C as projection, N as singleQuery };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./commands.cjs"),t=require("./frameworkErrors.cjs"),n=require("./exactJson.cjs"),r=require("./developmentCaller.cjs"),i=require("./http.cjs"),a=require("./manifest.cjs"),o=require("./wire.cjs"),s=require("./problem.cjs"),c=require("./queries.cjs"),l=require("./state.cjs"),u=require("./wait.cjs");exports.CommandClient=e.CommandClient,exports.CommandRejectedError=s.CommandRejectedError,exports.CommandResultStatus=o.CommandResultStatus,exports.DEFAULT_RETRY=t.DEFAULT_RETRY,exports.DatasetClient=c.DatasetClient,exports.DevelopmentCallerHeaders=r.DevelopmentCallerHeaders,exports.EventQueryClient=c.EventQueryClient,exports.FRAMEWORK_ERROR_PREFIX=s.FRAMEWORK_ERROR_PREFIX,exports.FRAMEWORK_RETRIES=t.FRAMEWORK_RETRIES,exports.FrameworkErrorCodes=t.FrameworkErrorCodes,exports.FunctionKind=o.FunctionKind,exports.LifecycleCommands=e.LifecycleCommands,exports.MANIFEST_FEATURES=a.MANIFEST_FEATURES,exports.MANIFEST_FORMAT=a.MANIFEST_FORMAT,exports.OwnStateClient=l.OwnStateClient,exports.PROBLEM_TYPE_PREFIX=s.PROBLEM_TYPE_PREFIX,exports.QUERYABLE_SUBSCRIPTION=u.QUERYABLE_SUBSCRIPTION,exports.QueryModelClient=c.QueryModelClient,exports.SNAPSHOT_SUBSCRIPTION=u.SNAPSHOT_SUBSCRIPTION,exports.SnapshotQueryClient=c.SnapshotQueryClient,exports.Stage=o.Stage,exports.StateClient=l.StateClient,exports.WaitPlan=u.WaitPlan,exports.WowHeaders=i.WowHeaders,exports.WowProblemError=s.WowProblemError,exports.checkManifest=a.checkManifest,exports.developmentCaller=r.developmentCaller,exports.developmentCallerHeaders=r.developmentCallerHeaders,exports.fetchManifest=a.fetchManifest,exports.formatHop=u.formatHop,exports.formatScope=i.formatScope,exports.formatWaitPlan=u.formatWaitPlan,exports.formatWaitTimeout=u.formatWaitTimeout,exports.isProblem=s.isProblem,exports.newRequestId=e.newRequestId,exports.parseHop=u.parseHop,exports.parseJson=n.parseJson,exports.parseRetryAfter=s.parseRetryAfter,exports.parseWaitPlan=u.parseWaitPlan,exports.queryPath=c.queryPath,exports.readProblem=s.readProblem,exports.requestIdOf=s.requestIdOf,exports.retryOf=s.retryOf,exports.stringifyJson=n.stringifyJson,exports.textNumberOr=n.textNumberOr,exports.textNumbersBy=n.textNumbersBy,exports.toWowProblemError=s.toWowProblemError,exports.wait=u.wait;
|
package/dist/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DEFAULT_RETRY as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { WowHeaders as
|
|
6
|
-
import { MANIFEST_FEATURES as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
export {
|
|
1
|
+
import { CommandClient as e, LifecycleCommands as t, newRequestId as n } from "./commands.es.js";
|
|
2
|
+
import { DEFAULT_RETRY as r, FRAMEWORK_RETRIES as i, FrameworkErrorCodes as a } from "./frameworkErrors.es.js";
|
|
3
|
+
import { parseJson as o, stringifyJson as s, textNumberOr as c, textNumbersBy as l } from "./exactJson.es.js";
|
|
4
|
+
import { DevelopmentCallerHeaders as u, developmentCaller as d, developmentCallerHeaders as f } from "./developmentCaller.es.js";
|
|
5
|
+
import { WowHeaders as p, formatScope as m } from "./http.es.js";
|
|
6
|
+
import { MANIFEST_FEATURES as h, MANIFEST_FORMAT as g, checkManifest as _, fetchManifest as v } from "./manifest.es.js";
|
|
7
|
+
import { CommandResultStatus as y, FunctionKind as b, Stage as x } from "./wire.es.js";
|
|
8
|
+
import { CommandRejectedError as S, FRAMEWORK_ERROR_PREFIX as C, PROBLEM_TYPE_PREFIX as w, WowProblemError as T, isProblem as E, parseRetryAfter as D, readProblem as O, requestIdOf as k, retryOf as A, toWowProblemError as j } from "./problem.es.js";
|
|
9
|
+
import { DatasetClient as M, EventQueryClient as N, QueryModelClient as P, SnapshotQueryClient as F, queryPath as I } from "./queries.es.js";
|
|
10
|
+
import { OwnStateClient as L, StateClient as R } from "./state.es.js";
|
|
11
|
+
import { QUERYABLE_SUBSCRIPTION as z, SNAPSHOT_SUBSCRIPTION as B, WaitPlan as V, formatHop as H, formatWaitPlan as U, formatWaitTimeout as W, parseHop as G, parseWaitPlan as K, wait as q } from "./wait.es.js";
|
|
12
|
+
export { e as CommandClient, S as CommandRejectedError, y as CommandResultStatus, r as DEFAULT_RETRY, M as DatasetClient, u as DevelopmentCallerHeaders, N as EventQueryClient, C as FRAMEWORK_ERROR_PREFIX, i as FRAMEWORK_RETRIES, a as FrameworkErrorCodes, b as FunctionKind, t as LifecycleCommands, h as MANIFEST_FEATURES, g as MANIFEST_FORMAT, L as OwnStateClient, w as PROBLEM_TYPE_PREFIX, z as QUERYABLE_SUBSCRIPTION, P as QueryModelClient, B as SNAPSHOT_SUBSCRIPTION, F as SnapshotQueryClient, x as Stage, R as StateClient, V as WaitPlan, p as WowHeaders, T as WowProblemError, _ as checkManifest, d as developmentCaller, f as developmentCallerHeaders, v as fetchManifest, H as formatHop, m as formatScope, U as formatWaitPlan, W as formatWaitTimeout, E as isProblem, n as newRequestId, G as parseHop, o as parseJson, D as parseRetryAfter, K as parseWaitPlan, I as queryPath, O as readProblem, k as requestIdOf, A as retryOf, s as stringifyJson, c as textNumberOr, l as textNumbersBy, j as toWowProblemError, q as wait };
|
package/dist/manifest.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./
|
|
1
|
+
const e=require("./http.cjs"),t=require("./problem.cjs");var n=1,r=new Set;function i(e){if(e.format!==1)throw TypeError(`The Manifest is of format ${e.format}; this client reads format 1.`);let t=(e.requires??[]).filter(e=>!r.has(e));if(t.length>0)throw TypeError(`The Manifest requires ${t.join(`, `)}, which this client does not understand: use a newer @ahoo-wang/wow-client.`);return e}async function a(t={},n){return i(await(await e.send(t,{method:`GET`,path:`/wow/manifest`,numbers:{},options:n})).json())}var o=class{constructor(e,t){this.client=e,this.manifest=t===void 0?void 0:Promise.resolve(i(t))}read(e){if(e?.aborted)return Promise.reject(e.reason);let t=this.manifest??=a(this.client).catch(e=>{throw this.manifest=void 0,e});return new Promise((n,r)=>{let i=()=>r(e.reason);e?.addEventListener(`abort`,i,{once:!0}),t.then(n,e=>r(s(e))).finally(()=>e?.removeEventListener(`abort`,i))})}};function s(e){if(e instanceof t.WowProblemError)return new t.WowProblemError(e.problem,{cause:e,...e.retryAfterMs===void 0?{}:{retryAfterMs:e.retryAfterMs}});let n=e instanceof Error?e:void 0;return Object.assign(Error(`The service's Manifest (GET /wow/manifest) could not be read: ${n?.message??String(e)}`),{name:n?.name??`Error`,cause:n?.cause??e})}exports.MANIFEST_FEATURES=r,exports.MANIFEST_FORMAT=n,exports.ManifestSource=o,exports.checkManifest=i,exports.fetchManifest=a;
|
|
2
2
|
//# sourceMappingURL=manifest.cjs.map
|