quetch 0.30.0 → 0.31.0
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/tools/comparatorFieldValues.d.ts +8 -0
- package/dist/tools/comparatorFieldValues.js +26 -0
- package/dist/tools/comparatorFieldValues.js.map +1 -0
- package/dist/tools/get.d.ts +4 -4
- package/dist/tools/get.js +6 -2
- package/dist/tools/get.js.map +1 -1
- package/dist/tools/querySettings.d.ts +8 -0
- package/dist/tools/querySettings.js +16 -0
- package/dist/tools/querySettings.js.map +1 -0
- package/dist/tools/sortItemList.d.ts +4 -4
- package/dist/tools/sortItemList.js +17 -24
- package/dist/tools/sortItemList.js.map +1 -1
- package/dist/tools/transformerFilterChildren.d.ts +2 -22
- package/dist/tools/transformerFilterChildren.js +1 -4
- package/dist/tools/transformerFilterChildren.js.map +1 -1
- package/dist/tools.d.ts +2 -0
- package/dist/tools.js +2 -0
- package/dist/tools.js.map +1 -1
- package/dist/types/CombineUnion.d.ts +1 -1
- package/dist/types/Decrement.d.ts +4 -0
- package/dist/types/Decrement.js +1 -0
- package/dist/types/Decrement.js.map +1 -0
- package/dist/types/DepthLimit.d.ts +1 -0
- package/dist/types/DepthLimit.js +1 -0
- package/dist/types/DepthLimit.js.map +1 -0
- package/dist/types/FieldKey.d.ts +2 -1
- package/dist/types/Get.d.ts +3 -1
- package/dist/types/KeyFiltered.d.ts +1 -1
- package/dist/types/NormalizedPathFieldSettings.d.ts +24 -0
- package/dist/types/NormalizedPathFieldSettings.js +1 -0
- package/dist/types/NormalizedPathFieldSettings.js.map +1 -0
- package/dist/types/Path.d.ts +4 -3
- package/dist/types/PathFiltered.d.ts +4 -3
- package/dist/types/QuerySettings.d.ts +12 -17
- package/dist/types.d.ts +3 -1
- package/doc/README.md +5 -1
- package/doc/classes/RequestError.md +5 -5
- package/doc/functions/aggregate.md +1 -1
- package/doc/functions/branch.md +1 -1
- package/doc/functions/cache.md +1 -1
- package/doc/functions/combine.md +1 -1
- package/doc/functions/comparatorFieldValues.md +33 -0
- package/doc/functions/cork.md +1 -1
- package/doc/functions/defineCheckQuery.md +1 -1
- package/doc/functions/defineCustomFetch.md +1 -1
- package/doc/functions/defineGenericFetch.md +1 -1
- package/doc/functions/escapeRegex.md +1 -1
- package/doc/functions/fetchExternal.md +1 -1
- package/doc/functions/fetchLocal.md +1 -1
- package/doc/functions/fieldListFromFilter.md +1 -1
- package/doc/functions/filterChildren.md +1 -1
- package/doc/functions/filterFromValue.md +1 -1
- package/doc/functions/get.md +2 -2
- package/doc/functions/groupFilters.md +1 -1
- package/doc/functions/identity.md +1 -1
- package/doc/functions/intrinsicFilter.md +1 -1
- package/doc/functions/isFilterGroup.md +1 -1
- package/doc/functions/log.md +1 -1
- package/doc/functions/normalizeOrder.md +1 -1
- package/doc/functions/queryItemList.md +1 -1
- package/doc/functions/querySettings.md +33 -0
- package/doc/functions/retry.md +1 -1
- package/doc/functions/reverseOrder.md +1 -1
- package/doc/functions/sameField.md +1 -1
- package/doc/functions/sortItemList.md +2 -2
- package/doc/functions/splitPath.md +2 -2
- package/doc/functions/testFilter.md +1 -1
- package/doc/functions/transformerFilterChildren.md +2 -2
- package/doc/interfaces/CustomFetch.md +1 -1
- package/doc/type-aliases/AggregateFunction.md +1 -1
- package/doc/type-aliases/AggregateFunctionOperator.md +1 -1
- package/doc/type-aliases/CombineUnion.md +2 -2
- package/doc/type-aliases/Context.md +1 -1
- package/doc/type-aliases/CustomFieldAggregateMap.md +1 -1
- package/doc/type-aliases/CustomFieldMap.md +1 -1
- package/doc/type-aliases/Decrement.md +17 -0
- package/doc/type-aliases/DepthLimit.md +13 -0
- package/doc/type-aliases/Field.md +1 -1
- package/doc/type-aliases/FieldFiltered.md +1 -1
- package/doc/type-aliases/FieldFunction.md +1 -1
- package/doc/type-aliases/FieldFunctionCustom.md +1 -1
- package/doc/type-aliases/FieldFunctionFormatDate.md +1 -1
- package/doc/type-aliases/FieldFunctionReturn.md +1 -1
- package/doc/type-aliases/FieldKey.md +2 -2
- package/doc/type-aliases/FieldMap.md +1 -1
- package/doc/type-aliases/Filter.md +1 -1
- package/doc/type-aliases/FilterArray.md +1 -1
- package/doc/type-aliases/FilterBoolean.md +1 -1
- package/doc/type-aliases/FilterChildren.md +1 -1
- package/doc/type-aliases/FilterCustom.md +1 -1
- package/doc/type-aliases/FilterField.md +1 -1
- package/doc/type-aliases/FilterGroup.md +1 -1
- package/doc/type-aliases/FilterNumber.md +1 -1
- package/doc/type-aliases/FilterOperator.md +1 -1
- package/doc/type-aliases/FilterString.md +1 -1
- package/doc/type-aliases/FilterStringIntersect.md +1 -1
- package/doc/type-aliases/FilterStringMatch.md +1 -1
- package/doc/type-aliases/Get.md +5 -3
- package/doc/type-aliases/Group.md +1 -1
- package/doc/type-aliases/Handler.md +1 -1
- package/doc/type-aliases/Immutable.md +1 -1
- package/doc/type-aliases/InjectCustomFields.md +1 -1
- package/doc/type-aliases/IntersectUnion.md +1 -1
- package/doc/type-aliases/IntrinsicFilter.md +1 -1
- package/doc/type-aliases/Item.md +1 -1
- package/doc/type-aliases/Join.md +1 -1
- package/doc/type-aliases/Key.md +1 -1
- package/doc/type-aliases/KeyFiltered.md +2 -2
- package/doc/type-aliases/KeyFromUnion.md +1 -1
- package/doc/type-aliases/Locale.md +1 -1
- package/doc/type-aliases/NextHandler.md +1 -1
- package/doc/type-aliases/NormalizedPathFieldSettings.md +57 -0
- package/doc/type-aliases/Order.md +1 -1
- package/doc/type-aliases/OrderNormalized.md +1 -1
- package/doc/type-aliases/Parameters.md +1 -1
- package/doc/type-aliases/Path.md +3 -3
- package/doc/type-aliases/PathFiltered.md +3 -3
- package/doc/type-aliases/Primitive.md +1 -1
- package/doc/type-aliases/PrimitiveObject.md +1 -1
- package/doc/type-aliases/Query.md +1 -1
- package/doc/type-aliases/QueryAggregate.md +1 -1
- package/doc/type-aliases/QueryCreate.md +1 -1
- package/doc/type-aliases/QueryCreateMultiple.md +1 -1
- package/doc/type-aliases/QueryDelete.md +1 -1
- package/doc/type-aliases/QueryDeleteMultiple.md +1 -1
- package/doc/type-aliases/QueryMethod.md +1 -1
- package/doc/type-aliases/QueryRead.md +1 -1
- package/doc/type-aliases/QueryReadMultiple.md +1 -1
- package/doc/type-aliases/QuerySettings.md +36 -30
- package/doc/type-aliases/QueryUpdate.md +1 -1
- package/doc/type-aliases/QueryUpdateMultiple.md +1 -1
- package/doc/type-aliases/Result.md +1 -1
- package/doc/type-aliases/Store.md +1 -1
- package/doc/type-aliases/Value.md +1 -1
- package/doc/type-aliases/ValueMap.md +1 -1
- package/doc/variables/CACHE.md +1 -1
- package/doc/variables/FILTER_ANY.md +1 -1
- package/doc/variables/FILTER_NONE.md +1 -1
- package/doc/variables/SELF.md +1 -1
- package/lib/tools/comparatorFieldValues.ts +46 -0
- package/lib/tools/get.ts +9 -4
- package/lib/tools/querySettings.ts +20 -0
- package/lib/tools/sortItemList.test.ts +31 -8
- package/lib/tools/sortItemList.ts +21 -41
- package/lib/tools/testFilter.test.ts +35 -12
- package/lib/tools/transformerFilterChildren.ts +3 -26
- package/lib/tools.ts +2 -0
- package/lib/types/CombineUnion.ts +12 -10
- package/lib/types/Decrement.ts +5 -0
- package/lib/types/DepthLimit.ts +1 -0
- package/lib/types/FieldKey.ts +6 -1
- package/lib/types/Get.ts +17 -9
- package/lib/types/KeyFiltered.ts +14 -10
- package/lib/types/NormalizedPathFieldSettings.ts +25 -0
- package/lib/types/Path.ts +18 -15
- package/lib/types/PathFiltered.ts +20 -17
- package/lib/types/QuerySettings.ts +16 -17
- package/lib/types.ts +3 -1
- package/package.json +2 -2
- package/dist/types/Increment.d.ts +0 -4
- package/dist/types/Increment.js +0 -1
- package/dist/types/Increment.js.map +0 -1
- package/doc/type-aliases/Increment.md +0 -17
- package/lib/types/Increment.ts +0 -5
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NormalizedPathFieldSettings, QuerySettings } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a function that transforms a `FilterChildren` into a `FilterStringMatch`.
|
|
4
|
+
*
|
|
5
|
+
* @param options - Options for the transformer.
|
|
6
|
+
* @returns A function that takes a `FilterChildren` and returns a `FilterStringMatch` that matches the paths of the children of the item specified in the `FilterChildren`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function comparatorFieldValues<T>({ pathField, pathFieldSeparator, pathFieldSeparatorEscape, }?: NormalizedPathFieldSettings<T>): QuerySettings<T>["compareFieldValues"];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EMPTY_OBJECT } from "unchangeable";
|
|
2
|
+
import { escapeRegex } from "./escapeRegex.js";
|
|
3
|
+
import { sameField } from "./sameField.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns a function that transforms a `FilterChildren` into a `FilterStringMatch`.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Options for the transformer.
|
|
8
|
+
* @returns A function that takes a `FilterChildren` and returns a `FilterStringMatch` that matches the paths of the children of the item specified in the `FilterChildren`.
|
|
9
|
+
*/
|
|
10
|
+
export function comparatorFieldValues({ pathField = "path", pathFieldSeparator = "/", pathFieldSeparatorEscape = "\\", } = EMPTY_OBJECT) {
|
|
11
|
+
const fieldSeparatorRegexp = new RegExp(!pathFieldSeparatorEscape
|
|
12
|
+
? escapeRegex(pathFieldSeparator)
|
|
13
|
+
: `(?<!${escapeRegex(pathFieldSeparatorEscape)})${escapeRegex(pathFieldSeparator)}`, "g");
|
|
14
|
+
return (field, a, b) => {
|
|
15
|
+
if (!sameField(field, pathField)) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const normalizedA = a.replaceAll?.(fieldSeparatorRegexp, "\x00");
|
|
19
|
+
const normalizedB = b.replaceAll?.(fieldSeparatorRegexp, "\x00");
|
|
20
|
+
if (normalizedA > normalizedB) {
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
return -1;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=comparatorFieldValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparatorFieldValues.js","sourceRoot":"","sources":["../../lib/tools/comparatorFieldValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAQ5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAI,EACvC,SAAS,GAAG,MAAkC,EAC9C,kBAAkB,GAAG,GAAG,EACxB,wBAAwB,GAAG,IAAI,MACG,YAAY;IAC9C,MAAM,oBAAoB,GAAG,IAAI,MAAM,CACrC,CAAC,wBAAwB;QACvB,CAAC,CAAC,WAAW,CAAC,kBAAkB,CAAC;QACjC,CAAC,CAAC,OAAO,WAAW,CAAC,wBAAwB,CAAC,IAAI,WAAW,CAAC,kBAAkB,CAAC,EAAE,EACrF,GAAG,CACJ,CAAC;IACF,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;QACrB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;YACjC,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,WAAW,GAAI,CAAY,CAAC,UAAU,EAAE,CAC5C,oBAAoB,EACpB,MAAM,CACP,CAAC;QACF,MAAM,WAAW,GAAI,CAAY,CAAC,UAAU,EAAE,CAC5C,oBAAoB,EACpB,MAAM,CACP,CAAC;QACF,IAAI,WAAW,GAAG,WAAW,EAAE,CAAC;YAC9B,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/tools/get.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Field, Get } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Gets the property value of the given `value` at the specified `path` (an array of object property names or array indexes).
|
|
4
4
|
* If the `path` is undefined, returns the `value` itself.
|
|
5
5
|
* If the `path` is a string, it is considered as a path with one item.
|
|
6
6
|
* If the `path` leads to an unknown property, returns `undefined`.
|
|
7
7
|
*
|
|
8
|
-
* @param value The value from which to get the property value.
|
|
9
|
-
* @param path The path leading to the property value or a property name or `undefined`.
|
|
8
|
+
* @param value - The value from which to get the property value.
|
|
9
|
+
* @param path - The path leading to the property value or a property name or `undefined`.
|
|
10
10
|
* @returns The property value found at the given path, or `undefined` if it cannot be found.
|
|
11
11
|
*/
|
|
12
|
-
export declare function get<const T, const P extends
|
|
12
|
+
export declare function get<const T, const P extends Field<T>>(value: T, path?: P): Get<T, P>;
|
package/dist/tools/get.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { SELF } from "../constants/SELF.js";
|
|
2
|
+
const { isArray } = Array;
|
|
2
3
|
/**
|
|
3
4
|
* Gets the property value of the given `value` at the specified `path` (an array of object property names or array indexes).
|
|
4
5
|
* If the `path` is undefined, returns the `value` itself.
|
|
5
6
|
* If the `path` is a string, it is considered as a path with one item.
|
|
6
7
|
* If the `path` leads to an unknown property, returns `undefined`.
|
|
7
8
|
*
|
|
8
|
-
* @param value The value from which to get the property value.
|
|
9
|
-
* @param path The path leading to the property value or a property name or `undefined`.
|
|
9
|
+
* @param value - The value from which to get the property value.
|
|
10
|
+
* @param path - The path leading to the property value or a property name or `undefined`.
|
|
10
11
|
* @returns The property value found at the given path, or `undefined` if it cannot be found.
|
|
11
12
|
*/
|
|
12
13
|
export function get(value, path) {
|
|
@@ -19,6 +20,9 @@ export function get(value, path) {
|
|
|
19
20
|
case "symbol":
|
|
20
21
|
return value?.[path];
|
|
21
22
|
default: {
|
|
23
|
+
if (!isArray(path)) {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
22
26
|
switch (path.length) {
|
|
23
27
|
case 0:
|
|
24
28
|
return value;
|
package/dist/tools/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CACjE,IAAY,CAAC,CAAC,CAAQ,CACxB,CAAC;gBACJ,KAAK,CAAC;oBACJ,OAAQ,KAAa,EAAE,CAAC,IAAI,CAAC,CAAC,CAAQ,CAAC,EAAE,CAAE,IAAY,CAAC,CAAC,CAAQ,CAAC,EAAE,CACjE,IAAY,CAAC,CAAC,CAAQ,CACxB,EAAE,CAAE,IAAY,CAAC,CAAC,CAAQ,CAAC,CAAC;gBAC/B;oBACE,OAAO,IAAI,CAAC,MAAM,CAChB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAE,KAAa,EAAE,CAAC,GAAG,CAAC,EACrC,KAAK,CACC,CAAC;YACb,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NormalizedPathFieldSettings, QuerySettings } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Returns query settings for path fields.
|
|
4
|
+
*
|
|
5
|
+
* @param settings - Settings for normalizing path fields.
|
|
6
|
+
* @returns Query settings for path fields.
|
|
7
|
+
*/
|
|
8
|
+
export declare function querySettings<T>(settings?: NormalizedPathFieldSettings<T>): QuerySettings<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EMPTY_OBJECT } from "unchangeable";
|
|
2
|
+
import { comparatorFieldValues } from "./comparatorFieldValues.js";
|
|
3
|
+
import { transformerFilterChildren } from "./transformerFilterChildren.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns query settings for path fields.
|
|
6
|
+
*
|
|
7
|
+
* @param settings - Settings for normalizing path fields.
|
|
8
|
+
* @returns Query settings for path fields.
|
|
9
|
+
*/
|
|
10
|
+
export function querySettings(settings = EMPTY_OBJECT) {
|
|
11
|
+
return {
|
|
12
|
+
compareFieldValues: comparatorFieldValues(settings),
|
|
13
|
+
transformFilterChildren: transformerFilterChildren(settings),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=querySettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"querySettings.js","sourceRoot":"","sources":["../../lib/tools/querySettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,WAA2C,YAAY;IAEvD,OAAO;QACL,kBAAkB,EAAE,qBAAqB,CAAC,QAAQ,CAAC;QACnD,uBAAuB,EAAE,yBAAyB,CAAC,QAAQ,CAAC;KAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -2,9 +2,9 @@ import type { Order, QuerySettings } from "../types";
|
|
|
2
2
|
/**
|
|
3
3
|
* Sorts provided `value` array according to the `orderList`.
|
|
4
4
|
*
|
|
5
|
-
* @param orderList The order to use for sorting.
|
|
6
|
-
* @param value The array to sort.
|
|
7
|
-
* @param settings Optional query settings.
|
|
5
|
+
* @param orderList - The order to use for sorting.
|
|
6
|
+
* @param value - The array to sort.
|
|
7
|
+
* @param settings - Optional query settings.
|
|
8
8
|
* @returns A new sorted array.
|
|
9
9
|
*/
|
|
10
|
-
export declare function sortItemList<T>(orderList: readonly Order<T>[] | undefined, value: readonly T[], settings?: QuerySettings<T>): readonly T[];
|
|
10
|
+
export declare function sortItemList<T>(orderList: NoInfer<readonly Order<T>[]> | undefined, value: readonly T[], settings?: QuerySettings<T>): readonly T[];
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EMPTY_OBJECT } from "unchangeable";
|
|
2
2
|
import { get } from "./get.js";
|
|
3
3
|
import { normalizeOrder } from "./normalizeOrder.js";
|
|
4
|
-
import { sameField } from "./sameField.js";
|
|
5
4
|
/**
|
|
6
5
|
* Sorts provided `value` array according to the `orderList`.
|
|
7
6
|
*
|
|
8
|
-
* @param orderList The order to use for sorting.
|
|
9
|
-
* @param value The array to sort.
|
|
10
|
-
* @param settings Optional query settings.
|
|
7
|
+
* @param orderList - The order to use for sorting.
|
|
8
|
+
* @param value - The array to sort.
|
|
9
|
+
* @param settings - Optional query settings.
|
|
11
10
|
* @returns A new sorted array.
|
|
12
11
|
*/
|
|
13
12
|
export function sortItemList(orderList, value, settings) {
|
|
14
|
-
const { pathField, pathFieldSeparator = "/", pathFieldSeparatorEscape, } = settings ?? {};
|
|
15
13
|
if (orderList === undefined || orderList.length === 0) {
|
|
16
14
|
return value;
|
|
17
15
|
}
|
|
16
|
+
const { compareFieldValues } = settings ?? EMPTY_OBJECT;
|
|
18
17
|
const normalizedOrder = orderList.map(normalizeOrder);
|
|
19
|
-
const fieldSeparatorRegexp = pathField == null || pathFieldSeparator == null
|
|
20
|
-
? null
|
|
21
|
-
: new RegExp(!pathFieldSeparatorEscape
|
|
22
|
-
? escapeRegex(pathFieldSeparator)
|
|
23
|
-
: `(?<!${escapeRegex(pathFieldSeparatorEscape)})${escapeRegex(pathFieldSeparator)}`, "g");
|
|
24
18
|
return value.toSorted((a, b) => {
|
|
25
19
|
for (let index = 0; index < normalizedOrder.length; index++) {
|
|
26
20
|
const { field, descending } = normalizedOrder[index];
|
|
@@ -29,24 +23,23 @@ export function sortItemList(orderList, value, settings) {
|
|
|
29
23
|
if (valueA === valueB) {
|
|
30
24
|
continue;
|
|
31
25
|
}
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (normalizedA > normalizedB) {
|
|
26
|
+
if (valueA == null) {
|
|
27
|
+
return valueB == null ? 0 : descending ? 1 : -1;
|
|
28
|
+
}
|
|
29
|
+
if (valueB == null) {
|
|
30
|
+
return descending ? -1 : 1;
|
|
31
|
+
}
|
|
32
|
+
const comparison = compareFieldValues?.(field, valueA, valueB);
|
|
33
|
+
if (comparison === undefined) {
|
|
34
|
+
if (valueA > valueB) {
|
|
42
35
|
return descending ? -1 : 1;
|
|
43
36
|
}
|
|
44
37
|
return descending ? 1 : -1;
|
|
45
38
|
}
|
|
46
|
-
if (
|
|
47
|
-
|
|
39
|
+
if (comparison === 0) {
|
|
40
|
+
continue;
|
|
48
41
|
}
|
|
49
|
-
return descending ?
|
|
42
|
+
return descending ? -comparison : comparison;
|
|
50
43
|
}
|
|
51
44
|
return 0;
|
|
52
45
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortItemList.js","sourceRoot":"","sources":["../../lib/tools/sortItemList.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sortItemList.js","sourceRoot":"","sources":["../../lib/tools/sortItemList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,SAAmD,EACnD,KAAmB,EACnB,QAA2B;IAE3B,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,EAAE,kBAAkB,EAAE,GAAG,QAAQ,IAAI,YAAY,CAAC;IACxD,MAAM,eAAe,GAAG,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACtD,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YAC5D,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,eAAe,CAAC,KAAK,CAAE,CAAC;YACtD,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAC7B,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAC7B,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;gBACtB,SAAS;YACX,CAAC;YACD,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,OAAO,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,CAAC;YACD,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,CAAC;YACD,MAAM,UAAU,GAAG,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YAC/D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC7B,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;oBACpB,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7B,CAAC;gBACD,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,CAAC;YACD,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;gBACrB,SAAS;YACX,CAAC;YACD,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;QAC/C,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type TransformerFilterChildrenOptions<T> = {
|
|
3
|
-
/**
|
|
4
|
-
* Path to the field that contains the path value of an item, used for displaying items in a tree.
|
|
5
|
-
*
|
|
6
|
-
* @default "path"
|
|
7
|
-
*/
|
|
8
|
-
pathField?: FieldFiltered<T, string>;
|
|
9
|
-
/**
|
|
10
|
-
* String used to escape the separator.
|
|
11
|
-
*
|
|
12
|
-
* @default "\\"
|
|
13
|
-
*/
|
|
14
|
-
pathFieldSeparatorEscape?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Maps path fields to a string used to separate the path nodes of a field value.
|
|
17
|
-
*
|
|
18
|
-
* @default "/"
|
|
19
|
-
*/
|
|
20
|
-
pathFieldSeparator?: string;
|
|
21
|
-
};
|
|
1
|
+
import type { FilterChildren, FilterStringMatch, NormalizedPathFieldSettings } from "../types";
|
|
22
2
|
/**
|
|
23
3
|
* Returns a function that transforms a `FilterChildren` into a `FilterStringMatch`.
|
|
24
4
|
*
|
|
25
5
|
* @param options - Options for the transformer.
|
|
26
6
|
* @returns A function that takes a `FilterChildren` and returns a `FilterStringMatch` that matches the paths of the children of the item specified in the `FilterChildren`.
|
|
27
7
|
*/
|
|
28
|
-
export declare function transformerFilterChildren<T>({ pathField, pathFieldSeparator, }?:
|
|
8
|
+
export declare function transformerFilterChildren<T>({ pathField, pathFieldSeparator, }?: NormalizedPathFieldSettings<T>): (filter: FilterChildren<T>) => FilterStringMatch<T>;
|
|
@@ -10,10 +10,7 @@ import { get } from "./get.js";
|
|
|
10
10
|
export function transformerFilterChildren({ pathField = "path", pathFieldSeparator = "/", } = EMPTY_OBJECT) {
|
|
11
11
|
return (filter) => {
|
|
12
12
|
const { value, minDepth = 1, maxDepth = Infinity } = filter;
|
|
13
|
-
|
|
14
|
-
throw new Error("FilterChildren must have a value");
|
|
15
|
-
}
|
|
16
|
-
const parentPath = get(value, pathField);
|
|
13
|
+
const parentPath = (get(value, pathField) ?? "");
|
|
17
14
|
return filterChildren(parentPath, pathField, minDepth, maxDepth, pathFieldSeparator);
|
|
18
15
|
};
|
|
19
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformerFilterChildren.js","sourceRoot":"","sources":["../../lib/tools/transformerFilterChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"transformerFilterChildren.js","sourceRoot":"","sources":["../../lib/tools/transformerFilterChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAS5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAI,EAC3C,SAAS,GAAG,MAAkC,EAC9C,kBAAkB,GAAG,GAAG,MACU,YAAY;IAC9C,OAAO,CAAC,MAAyB,EAAwB,EAAE;QACzD,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,GAAG,MAAM,CAAC;QAC5D,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,SAAgB,CAAC,IAAI,EAAE,CAAW,CAAC;QAClE,OAAO,cAAc,CACnB,UAAU,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,kBAAkB,CACnB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { comparatorFieldValues } from "./tools/comparatorFieldValues.js";
|
|
1
2
|
export { cork } from "./tools/cork.js";
|
|
2
3
|
export { defineCheckQuery } from "./tools/defineCheckQuery.js";
|
|
3
4
|
export { defineCustomFetch } from "./tools/defineCustomFetch.js";
|
|
@@ -12,6 +13,7 @@ export { intrinsicFilter } from "./tools/intrinsicFilter.js";
|
|
|
12
13
|
export { isFilterGroup } from "./tools/isFilterGroup.js";
|
|
13
14
|
export { normalizeOrder } from "./tools/normalizeOrder.js";
|
|
14
15
|
export { queryItemList } from "./tools/queryItemList.js";
|
|
16
|
+
export { querySettings } from "./tools/querySettings.js";
|
|
15
17
|
export { reverseOrder } from "./tools/reverseOrder.js";
|
|
16
18
|
export { sameField } from "./tools/sameField.js";
|
|
17
19
|
export { sortItemList } from "./tools/sortItemList.js";
|
package/dist/tools.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// File automatically generated by `vite-plugin-module-list`
|
|
2
|
+
export { comparatorFieldValues } from "./tools/comparatorFieldValues.js";
|
|
2
3
|
export { cork } from "./tools/cork.js";
|
|
3
4
|
export { defineCheckQuery } from "./tools/defineCheckQuery.js";
|
|
4
5
|
export { defineCustomFetch } from "./tools/defineCustomFetch.js";
|
|
@@ -13,6 +14,7 @@ export { intrinsicFilter } from "./tools/intrinsicFilter.js";
|
|
|
13
14
|
export { isFilterGroup } from "./tools/isFilterGroup.js";
|
|
14
15
|
export { normalizeOrder } from "./tools/normalizeOrder.js";
|
|
15
16
|
export { queryItemList } from "./tools/queryItemList.js";
|
|
17
|
+
export { querySettings } from "./tools/querySettings.js";
|
|
16
18
|
export { reverseOrder } from "./tools/reverseOrder.js";
|
|
17
19
|
export { sameField } from "./tools/sameField.js";
|
|
18
20
|
export { sortItemList } from "./tools/sortItemList.js";
|
package/dist/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../lib/tools.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,cAAc,E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M,4BAA4B,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { KeyFromUnion } from "./KeyFromUnion";
|
|
2
2
|
import type { Primitive } from "./Primitive";
|
|
3
|
-
export type CombineUnion<U> = [0] extends [1 & U] ? any : [U] extends [Function | readonly Function[]] ? undefined : [U] extends [Primitive] ? U : [U] extends readonly [Array<any>] ? U : {
|
|
3
|
+
export type CombineUnion<U> = [unknown] extends [U] ? unknown : [0] extends [1 & U] ? any : [U] extends [Function | readonly Function[]] ? undefined : [U] extends [Primitive] ? U : [U] extends readonly [Array<any>] ? U : {
|
|
4
4
|
[K in KeyFromUnion<U>]: Continue<Combine<U, K>>;
|
|
5
5
|
};
|
|
6
6
|
type Combine<U, K extends string | number | symbol> = Exclude<Extract<U, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=Decrement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Decrement.js","sourceRoot":"","sources":["../../lib/types/Decrement.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DepthLimit = 4;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=DepthLimit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DepthLimit.js","sourceRoot":"","sources":["../../lib/types/DepthLimit.ts"],"names":[],"mappings":""}
|
package/dist/types/FieldKey.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { SELF } from "../constants/SELF.ts";
|
|
2
|
+
import type { Key } from "./Key.ts";
|
|
2
3
|
import type { Primitive } from "./Primitive";
|
|
3
|
-
export type FieldKey<T> = T extends Primitive ? typeof SELF : keyof T;
|
|
4
|
+
export type FieldKey<T> = T extends Primitive ? typeof SELF : [unknown] extends [T] ? Key : keyof T;
|
package/dist/types/Get.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Decrement } from "./Decrement";
|
|
2
|
+
import type { DepthLimit } from "./DepthLimit";
|
|
1
3
|
import type { Path } from "./Path";
|
|
2
4
|
/**
|
|
3
5
|
* Returns the type of the property at the specified `P` path.
|
|
4
6
|
*/
|
|
5
|
-
export type Get<T, P> = [P] extends [readonly [infer K, ...infer R]] ? K extends keyof T ? R extends Path<T[K]> ? Get<T[K], R
|
|
7
|
+
export type Get<T, P, D = DepthLimit> = [unknown] extends [T] ? unknown : [0] extends [1 & T] ? any : D extends -1 ? any : [P] extends [readonly [infer K, ...infer R]] ? K extends keyof T ? R extends Path<T[K]> ? Get<T[K], R, Decrement<D>> : T[K] : never : [P] extends [keyof T] ? T[P] : T;
|
|
@@ -4,7 +4,7 @@ type SymbolSelf = typeof SELF;
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns union of keys whose mapped value extend the provided `P` type.
|
|
6
6
|
*/
|
|
7
|
-
export type KeyFiltered<T, P> = [0] extends [1 & T] ? Key | SymbolSelf : T extends string | number | boolean | bigint | symbol ? T extends P ? SymbolSelf : never : T extends object ? keyof {
|
|
7
|
+
export type KeyFiltered<T, P> = [unknown] extends [T] ? Key | SymbolSelf : [0] extends [1 & T] ? Key | SymbolSelf : T extends string | number | boolean | bigint | symbol ? T extends P ? SymbolSelf : never : T extends object ? keyof {
|
|
8
8
|
[K in keyof T as Extract<T[K], P> extends never ? never : K]-?: T[K];
|
|
9
9
|
} : never;
|
|
10
10
|
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FieldFiltered } from "./FieldFiltered";
|
|
2
|
+
/**
|
|
3
|
+
* Settings for fields that contain path values of items, used for displaying items in a tree.
|
|
4
|
+
*/
|
|
5
|
+
export type NormalizedPathFieldSettings<T> = {
|
|
6
|
+
/**
|
|
7
|
+
* Path to the field that contains the path value of an item, used for displaying items in a tree.
|
|
8
|
+
*
|
|
9
|
+
* @default "path"
|
|
10
|
+
*/
|
|
11
|
+
pathField?: FieldFiltered<T, string>;
|
|
12
|
+
/**
|
|
13
|
+
* String used to escape the separator.
|
|
14
|
+
*
|
|
15
|
+
* @default "\\"
|
|
16
|
+
*/
|
|
17
|
+
pathFieldSeparatorEscape?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Maps path fields to a string used to separate the path nodes of a field value.
|
|
20
|
+
*
|
|
21
|
+
* @default "/"
|
|
22
|
+
*/
|
|
23
|
+
pathFieldSeparator?: string;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=NormalizedPathFieldSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NormalizedPathFieldSettings.js","sourceRoot":"","sources":["../../lib/types/NormalizedPathFieldSettings.ts"],"names":[],"mappings":""}
|
package/dist/types/Path.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Decrement } from "./Decrement";
|
|
2
|
+
import type { DepthLimit } from "./DepthLimit";
|
|
2
3
|
import type { Key } from "./Key";
|
|
3
4
|
import type { Primitive } from "./Primitive";
|
|
4
|
-
export type Path<T, D =
|
|
5
|
-
[K in keyof T]: readonly [K] | readonly [K, ...Path<T[K],
|
|
5
|
+
export type Path<T, D = DepthLimit> = [unknown] extends [T] ? readonly (Key | never)[] : [0] extends [1 & T] ? readonly (Key | never)[] : D extends -1 ? never : T extends Primitive ? readonly never[] : T extends Array<infer P> ? readonly [number] | readonly [number, ...Path<P, Decrement<D>>] : T extends object ? {
|
|
6
|
+
[K in keyof T]: readonly [K] | readonly [K, ...Path<T[K], Decrement<D>>];
|
|
6
7
|
}[keyof T] : never;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Decrement } from "./Decrement";
|
|
2
|
+
import type { DepthLimit } from "./DepthLimit";
|
|
2
3
|
import type { Key } from "./Key";
|
|
3
|
-
export type PathFiltered<T, P, D =
|
|
4
|
-
[K in keyof T]: Extract<T[K], P> extends never ? readonly [K, ...PathFiltered<T[K], P,
|
|
4
|
+
export type PathFiltered<T, P, D = DepthLimit> = [unknown] extends [T] ? readonly (Key | never)[] : [0] extends [1 & T] ? readonly (Key | never)[] : D extends -1 ? never : T extends P ? readonly never[] : T extends ReadonlyArray<infer I> ? Extract<I, P> extends never ? readonly [number, ...PathFiltered<I, P, Decrement<D>>] : readonly [number] : T extends object ? {
|
|
5
|
+
[K in keyof T]: Extract<T[K], P> extends never ? readonly [K, ...PathFiltered<T[K], P, Decrement<D>>] : readonly [K];
|
|
5
6
|
}[keyof T] : never;
|
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Field } from "./Field";
|
|
2
2
|
import type { FilterChildren } from "./FilterChildren";
|
|
3
3
|
import type { IntrinsicFilter } from "./IntrinsicFilter";
|
|
4
4
|
/**
|
|
5
5
|
* Settings to use when doing a query.
|
|
6
6
|
*/
|
|
7
7
|
export type QuerySettings<T> = {
|
|
8
|
-
/**
|
|
9
|
-
* Path to the field that contains the path value of an item, used for displaying items in a tree.
|
|
10
|
-
*/
|
|
11
|
-
pathField?: FieldFiltered<T, string>;
|
|
12
|
-
/**
|
|
13
|
-
* String used to escape the separator.
|
|
14
|
-
*
|
|
15
|
-
* @default "\\"
|
|
16
|
-
*/
|
|
17
|
-
pathFieldSeparatorEscape?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Maps path fields to a string used to separate the path nodes of a field value.
|
|
20
|
-
*
|
|
21
|
-
* @default "/"
|
|
22
|
-
*/
|
|
23
|
-
pathFieldSeparator?: string;
|
|
24
8
|
/**
|
|
25
9
|
* Returns a filter that captures the items expressed by the provided `FilterChildren`. The return filter cannot use filters of type `FilterChildren` or `FilterContext`.
|
|
26
10
|
*
|
|
@@ -28,6 +12,17 @@ export type QuerySettings<T> = {
|
|
|
28
12
|
* @returns A filter that captures the items expressed by the provided `FilterChildren`.
|
|
29
13
|
*/
|
|
30
14
|
transformFilterChildren?: (filter: FilterChildren<T>) => IntrinsicFilter<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Compares two values of a field for sorting purposes. If not provided, values are compared using the default comparison operators (`>`, `<`, `===`).
|
|
17
|
+
*
|
|
18
|
+
* This function is called only when both `a` and `b` are defined and different. If it returns `undefined`, the default comparison operators are used as a fallback.
|
|
19
|
+
*
|
|
20
|
+
* @param a - The first value to compare.
|
|
21
|
+
* @param b - The second value to compare.
|
|
22
|
+
* @param field - The field for which the values are compared.
|
|
23
|
+
* @returns `-1` if `a` should be sorted before `b`, `1` if `a` should be sorted after `b`, `0` if they are considered equal, or `undefined` to use the default comparison operators.
|
|
24
|
+
*/
|
|
25
|
+
compareFieldValues?<T>(field: Field<T>, a: NonNullable<any>, b: NonNullable<any>): -1 | 0 | 1 | undefined;
|
|
31
26
|
/**
|
|
32
27
|
* Abort signal to abort the query.
|
|
33
28
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export type { Context } from "./types/Context";
|
|
|
5
5
|
export type { CustomFetch } from "./types/CustomFetch";
|
|
6
6
|
export type { CustomFieldAggregateMap } from "./types/CustomFieldAggregateMap";
|
|
7
7
|
export type { CustomFieldMap } from "./types/CustomFieldMap";
|
|
8
|
+
export type { Decrement } from "./types/Decrement";
|
|
9
|
+
export type { DepthLimit } from "./types/DepthLimit";
|
|
8
10
|
export type { Field } from "./types/Field";
|
|
9
11
|
export type { FieldFiltered } from "./types/FieldFiltered";
|
|
10
12
|
export type { FieldFunction } from "./types/FieldFunction";
|
|
@@ -29,7 +31,6 @@ export type { Get } from "./types/Get";
|
|
|
29
31
|
export type { Group } from "./types/Group";
|
|
30
32
|
export type { Handler } from "./types/Handler";
|
|
31
33
|
export type { Immutable } from "./types/Immutable";
|
|
32
|
-
export type { Increment } from "./types/Increment";
|
|
33
34
|
export type { InjectCustomFields } from "./types/InjectCustomFields";
|
|
34
35
|
export type { IntersectUnion } from "./types/IntersectUnion";
|
|
35
36
|
export type { IntrinsicFilter } from "./types/IntrinsicFilter";
|
|
@@ -40,6 +41,7 @@ export type { KeyFiltered } from "./types/KeyFiltered";
|
|
|
40
41
|
export type { KeyFromUnion } from "./types/KeyFromUnion";
|
|
41
42
|
export type { Locale } from "./types/Locale";
|
|
42
43
|
export type { NextHandler } from "./types/NextHandler";
|
|
44
|
+
export type { NormalizedPathFieldSettings } from "./types/NormalizedPathFieldSettings";
|
|
43
45
|
export type { Order } from "./types/Order";
|
|
44
46
|
export type { OrderNormalized } from "./types/OrderNormalized";
|
|
45
47
|
export type { Parameters } from "./types/Parameters";
|
package/doc/README.md
CHANGED
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
- [Context](type-aliases/Context.md)
|
|
21
21
|
- [CustomFieldAggregateMap](type-aliases/CustomFieldAggregateMap.md)
|
|
22
22
|
- [CustomFieldMap](type-aliases/CustomFieldMap.md)
|
|
23
|
+
- [Decrement](type-aliases/Decrement.md)
|
|
24
|
+
- [DepthLimit](type-aliases/DepthLimit.md)
|
|
23
25
|
- [Field](type-aliases/Field.md)
|
|
24
26
|
- [FieldFiltered](type-aliases/FieldFiltered.md)
|
|
25
27
|
- [FieldFunction](type-aliases/FieldFunction.md)
|
|
@@ -44,7 +46,6 @@
|
|
|
44
46
|
- [Group](type-aliases/Group.md)
|
|
45
47
|
- [Handler](type-aliases/Handler.md)
|
|
46
48
|
- [Immutable](type-aliases/Immutable.md)
|
|
47
|
-
- [Increment](type-aliases/Increment.md)
|
|
48
49
|
- [InjectCustomFields](type-aliases/InjectCustomFields.md)
|
|
49
50
|
- [IntersectUnion](type-aliases/IntersectUnion.md)
|
|
50
51
|
- [IntrinsicFilter](type-aliases/IntrinsicFilter.md)
|
|
@@ -55,6 +56,7 @@
|
|
|
55
56
|
- [KeyFromUnion](type-aliases/KeyFromUnion.md)
|
|
56
57
|
- [Locale](type-aliases/Locale.md)
|
|
57
58
|
- [NextHandler](type-aliases/NextHandler.md)
|
|
59
|
+
- [NormalizedPathFieldSettings](type-aliases/NormalizedPathFieldSettings.md)
|
|
58
60
|
- [Order](type-aliases/Order.md)
|
|
59
61
|
- [OrderNormalized](type-aliases/OrderNormalized.md)
|
|
60
62
|
- [Parameters](type-aliases/Parameters.md)
|
|
@@ -92,6 +94,7 @@
|
|
|
92
94
|
- [branch](functions/branch.md)
|
|
93
95
|
- [cache](functions/cache.md)
|
|
94
96
|
- [combine](functions/combine.md)
|
|
97
|
+
- [comparatorFieldValues](functions/comparatorFieldValues.md)
|
|
95
98
|
- [cork](functions/cork.md)
|
|
96
99
|
- [defineCheckQuery](functions/defineCheckQuery.md)
|
|
97
100
|
- [defineCustomFetch](functions/defineCustomFetch.md)
|
|
@@ -110,6 +113,7 @@
|
|
|
110
113
|
- [log](functions/log.md)
|
|
111
114
|
- [normalizeOrder](functions/normalizeOrder.md)
|
|
112
115
|
- [queryItemList](functions/queryItemList.md)
|
|
116
|
+
- [querySettings](functions/querySettings.md)
|
|
113
117
|
- [retry](functions/retry.md)
|
|
114
118
|
- [reverseOrder](functions/reverseOrder.md)
|
|
115
119
|
- [sameField](functions/sameField.md)
|
|
@@ -50,7 +50,7 @@ Error to be thrown in case there is an issue with the query call. Only instances
|
|
|
50
50
|
|
|
51
51
|
#### Defined in
|
|
52
52
|
|
|
53
|
-
[lib/errors/RequestError.ts:7](https://github.com/nevoland/quetch/blob/
|
|
53
|
+
[lib/errors/RequestError.ts:7](https://github.com/nevoland/quetch/blob/1cf615b166541d2a753e34c0a2dd4a9474026d7a/lib/errors/RequestError.ts#L7)
|
|
54
54
|
|
|
55
55
|
## Properties
|
|
56
56
|
|
|
@@ -60,7 +60,7 @@ Error to be thrown in case there is an issue with the query call. Only instances
|
|
|
60
60
|
|
|
61
61
|
#### Defined in
|
|
62
62
|
|
|
63
|
-
[lib/errors/RequestError.ts:10](https://github.com/nevoland/quetch/blob/
|
|
63
|
+
[lib/errors/RequestError.ts:10](https://github.com/nevoland/quetch/blob/1cf615b166541d2a753e34c0a2dd4a9474026d7a/lib/errors/RequestError.ts#L10)
|
|
64
64
|
|
|
65
65
|
***
|
|
66
66
|
|
|
@@ -70,7 +70,7 @@ Error to be thrown in case there is an issue with the query call. Only instances
|
|
|
70
70
|
|
|
71
71
|
#### Defined in
|
|
72
72
|
|
|
73
|
-
[lib/errors/RequestError.ts:11](https://github.com/nevoland/quetch/blob/
|
|
73
|
+
[lib/errors/RequestError.ts:11](https://github.com/nevoland/quetch/blob/1cf615b166541d2a753e34c0a2dd4a9474026d7a/lib/errors/RequestError.ts#L11)
|
|
74
74
|
|
|
75
75
|
***
|
|
76
76
|
|
|
@@ -80,7 +80,7 @@ Error to be thrown in case there is an issue with the query call. Only instances
|
|
|
80
80
|
|
|
81
81
|
#### Defined in
|
|
82
82
|
|
|
83
|
-
[lib/errors/RequestError.ts:12](https://github.com/nevoland/quetch/blob/
|
|
83
|
+
[lib/errors/RequestError.ts:12](https://github.com/nevoland/quetch/blob/1cf615b166541d2a753e34c0a2dd4a9474026d7a/lib/errors/RequestError.ts#L12)
|
|
84
84
|
|
|
85
85
|
***
|
|
86
86
|
|
|
@@ -90,4 +90,4 @@ Error to be thrown in case there is an issue with the query call. Only instances
|
|
|
90
90
|
|
|
91
91
|
#### Defined in
|
|
92
92
|
|
|
93
|
-
[lib/errors/RequestError.ts:9](https://github.com/nevoland/quetch/blob/
|
|
93
|
+
[lib/errors/RequestError.ts:9](https://github.com/nevoland/quetch/blob/1cf615b166541d2a753e34c0a2dd4a9474026d7a/lib/errors/RequestError.ts#L9)
|
|
@@ -58,4 +58,4 @@ If a query occurs twice, `mergeQuery(query, currentQuery)` is called and the out
|
|
|
58
58
|
|
|
59
59
|
## Defined in
|
|
60
60
|
|
|
61
|
-
[lib/middlewares/aggregate.ts:17](https://github.com/nevoland/quetch/blob/
|
|
61
|
+
[lib/middlewares/aggregate.ts:17](https://github.com/nevoland/quetch/blob/1cf615b166541d2a753e34c0a2dd4a9474026d7a/lib/middlewares/aggregate.ts#L17)
|
package/doc/functions/branch.md
CHANGED
|
@@ -49,4 +49,4 @@ const customFetch = combine(
|
|
|
49
49
|
|
|
50
50
|
## Defined in
|
|
51
51
|
|
|
52
|
-
[lib/middlewares/branch.ts:21](https://github.com/nevoland/quetch/blob/
|
|
52
|
+
[lib/middlewares/branch.ts:21](https://github.com/nevoland/quetch/blob/1cf615b166541d2a753e34c0a2dd4a9474026d7a/lib/middlewares/branch.ts#L21)
|
package/doc/functions/cache.md
CHANGED
|
@@ -68,4 +68,4 @@ Cache store.
|
|
|
68
68
|
|
|
69
69
|
## Defined in
|
|
70
70
|
|
|
71
|
-
[lib/middlewares/cache.ts:8](https://github.com/nevoland/quetch/blob/
|
|
71
|
+
[lib/middlewares/cache.ts:8](https://github.com/nevoland/quetch/blob/1cf615b166541d2a753e34c0a2dd4a9474026d7a/lib/middlewares/cache.ts#L8)
|
package/doc/functions/combine.md
CHANGED
|
@@ -116,4 +116,4 @@ Handler that combines all provided handlers.
|
|
|
116
116
|
|
|
117
117
|
## Defined in
|
|
118
118
|
|
|
119
|
-
[lib/middlewares/combine.ts:801](https://github.com/nevoland/quetch/blob/
|
|
119
|
+
[lib/middlewares/combine.ts:801](https://github.com/nevoland/quetch/blob/1cf615b166541d2a753e34c0a2dd4a9474026d7a/lib/middlewares/combine.ts#L801)
|